51e43722292a39ec769a5965745e118c3965cace
[ccsdk/sli.git] /
1 package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results;
2 import org.opendaylight.yangtools.yang.binding.Augmentation;
3 import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
4 import org.opendaylight.yangtools.yang.binding.DataObject;
5 import java.util.HashMap;
6 import org.opendaylight.yangtools.concepts.Builder;
7 import java.util.Objects;
8 import java.util.List;
9 import java.util.Collections;
10 import java.util.Map;
11
12 /**
13  * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult} instances.
14  *
15  * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult
16  *
17  */
18 public class TestResultBuilder implements Builder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult> {
19
20     private TestResultKey _key;
21     private List<java.lang.String> _results;
22     private java.lang.String _testIdentifier;
23
24     Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> augmentation = Collections.emptyMap();
25
26     public TestResultBuilder() {
27     }
28
29     public TestResultBuilder(TestResult base) {
30         if (base.getKey() == null) {
31             this._key = new TestResultKey(
32                 base.getTestIdentifier()
33             );
34             this._testIdentifier = base.getTestIdentifier();
35         } else {
36             this._key = base.getKey();
37             this._testIdentifier = _key.getTestIdentifier();
38         }
39         this._results = base.getResults();
40         if (base instanceof TestResultImpl) {
41             TestResultImpl impl = (TestResultImpl) base;
42             if (!impl.augmentation.isEmpty()) {
43                 this.augmentation = new HashMap<>(impl.augmentation);
44             }
45         } else if (base instanceof AugmentationHolder) {
46             @SuppressWarnings("unchecked")
47             AugmentationHolder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>) base;
48             if (!casted.augmentations().isEmpty()) {
49                 this.augmentation = new HashMap<>(casted.augmentations());
50             }
51         }
52     }
53
54
55     public TestResultKey getKey() {
56         return _key;
57     }
58     
59     public List<java.lang.String> getResults() {
60         return _results;
61     }
62     
63     public java.lang.String getTestIdentifier() {
64         return _testIdentifier;
65     }
66     
67     @SuppressWarnings("unchecked")
68     public <E extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> E getAugmentation(java.lang.Class<E> augmentationType) {
69         if (augmentationType == null) {
70             throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
71         }
72         return (E) augmentation.get(augmentationType);
73     }
74
75      
76     public TestResultBuilder setKey(final TestResultKey value) {
77         this._key = value;
78         return this;
79     }
80     
81      
82     public TestResultBuilder setResults(final List<java.lang.String> value) {
83         this._results = value;
84         return this;
85     }
86     
87      
88     public TestResultBuilder setTestIdentifier(final java.lang.String value) {
89         this._testIdentifier = value;
90         return this;
91     }
92     
93     public TestResultBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult> augmentation) {
94         if (augmentation == null) {
95             return removeAugmentation(augmentationType);
96         }
97     
98         if (!(this.augmentation instanceof HashMap)) {
99             this.augmentation = new HashMap<>();
100         }
101     
102         this.augmentation.put(augmentationType, augmentation);
103         return this;
104     }
105     
106     public TestResultBuilder removeAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> augmentationType) {
107         if (this.augmentation instanceof HashMap) {
108             this.augmentation.remove(augmentationType);
109         }
110         return this;
111     }
112
113     @Override
114     public TestResult build() {
115         return new TestResultImpl(this);
116     }
117
118     private static final class TestResultImpl implements TestResult {
119
120         @Override
121         public java.lang.Class<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult> getImplementedInterface() {
122             return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class;
123         }
124
125         private final TestResultKey _key;
126         private final List<java.lang.String> _results;
127         private final java.lang.String _testIdentifier;
128
129         private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> augmentation = Collections.emptyMap();
130
131         private TestResultImpl(TestResultBuilder base) {
132             if (base.getKey() == null) {
133                 this._key = new TestResultKey(
134                     base.getTestIdentifier()
135                 );
136                 this._testIdentifier = base.getTestIdentifier();
137             } else {
138                 this._key = base.getKey();
139                 this._testIdentifier = _key.getTestIdentifier();
140             }
141             this._results = base.getResults();
142             switch (base.augmentation.size()) {
143             case 0:
144                 this.augmentation = Collections.emptyMap();
145                 break;
146             case 1:
147                 final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> e = base.augmentation.entrySet().iterator().next();
148                 this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>>singletonMap(e.getKey(), e.getValue());
149                 break;
150             default :
151                 this.augmentation = new HashMap<>(base.augmentation);
152             }
153         }
154
155         @Override
156         public TestResultKey getKey() {
157             return _key;
158         }
159         
160         @Override
161         public List<java.lang.String> getResults() {
162             return _results;
163         }
164         
165         @Override
166         public java.lang.String getTestIdentifier() {
167             return _testIdentifier;
168         }
169         
170         @SuppressWarnings("unchecked")
171         @Override
172         public <E extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> E getAugmentation(java.lang.Class<E> augmentationType) {
173             if (augmentationType == null) {
174                 throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
175             }
176             return (E) augmentation.get(augmentationType);
177         }
178
179         private int hash = 0;
180         private volatile boolean hashValid = false;
181         
182         @Override
183         public int hashCode() {
184             if (hashValid) {
185                 return hash;
186             }
187         
188             final int prime = 31;
189             int result = 1;
190             result = prime * result + Objects.hashCode(_key);
191             result = prime * result + Objects.hashCode(_results);
192             result = prime * result + Objects.hashCode(_testIdentifier);
193             result = prime * result + Objects.hashCode(augmentation);
194         
195             hash = result;
196             hashValid = true;
197             return result;
198         }
199
200         @Override
201         public boolean equals(java.lang.Object obj) {
202             if (this == obj) {
203                 return true;
204             }
205             if (!(obj instanceof DataObject)) {
206                 return false;
207             }
208             if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class.equals(((DataObject)obj).getImplementedInterface())) {
209                 return false;
210             }
211             org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult)obj;
212             if (!Objects.equals(_key, other.getKey())) {
213                 return false;
214             }
215             if (!Objects.equals(_results, other.getResults())) {
216                 return false;
217             }
218             if (!Objects.equals(_testIdentifier, other.getTestIdentifier())) {
219                 return false;
220             }
221             if (getClass() == obj.getClass()) {
222                 // Simple case: we are comparing against self
223                 TestResultImpl otherImpl = (TestResultImpl) obj;
224                 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
225                     return false;
226                 }
227             } else {
228                 // Hard case: compare our augments with presence there...
229                 for (Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult>> e : augmentation.entrySet()) {
230                     if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
231                         return false;
232                     }
233                 }
234                 // .. and give the other one the chance to do the same
235                 if (!obj.equals(this)) {
236                     return false;
237                 }
238             }
239             return true;
240         }
241
242         @Override
243         public java.lang.String toString() {
244             java.lang.String name = "TestResult [";
245             java.lang.StringBuilder builder = new java.lang.StringBuilder (name);
246             if (_key != null) {
247                 builder.append("_key=");
248                 builder.append(_key);
249                 builder.append(", ");
250             }
251             if (_results != null) {
252                 builder.append("_results=");
253                 builder.append(_results);
254                 builder.append(", ");
255             }
256             if (_testIdentifier != null) {
257                 builder.append("_testIdentifier=");
258                 builder.append(_testIdentifier);
259             }
260             final int builderLength = builder.length();
261             final int builderAdditionalLength = builder.substring(name.length(), builderLength).length();
262             if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) {
263                 builder.append(", ");
264             }
265             builder.append("augmentation=");
266             builder.append(augmentation.values());
267             return builder.append(']').toString();
268         }
269     }
270
271 }