36da730edf6b0644f037eaf830e9c1ea5795d607
[ccsdk/sli.git] /
1 package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110;
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 org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult;
10 import java.util.Collections;
11 import java.util.Map;
12
13 /**
14  * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults} instances.
15  *
16  * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults
17  *
18  */
19 public class TestResultsBuilder implements Builder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults> {
20
21     private List<TestResult> _testResult;
22
23     Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> augmentation = Collections.emptyMap();
24
25     public TestResultsBuilder() {
26     }
27
28     public TestResultsBuilder(TestResults base) {
29         this._testResult = base.getTestResult();
30         if (base instanceof TestResultsImpl) {
31             TestResultsImpl impl = (TestResultsImpl) base;
32             if (!impl.augmentation.isEmpty()) {
33                 this.augmentation = new HashMap<>(impl.augmentation);
34             }
35         } else if (base instanceof AugmentationHolder) {
36             @SuppressWarnings("unchecked")
37             AugmentationHolder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>) base;
38             if (!casted.augmentations().isEmpty()) {
39                 this.augmentation = new HashMap<>(casted.augmentations());
40             }
41         }
42     }
43
44
45     public List<TestResult> getTestResult() {
46         return _testResult;
47     }
48     
49     @SuppressWarnings("unchecked")
50     public <E extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> E getAugmentation(java.lang.Class<E> augmentationType) {
51         if (augmentationType == null) {
52             throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
53         }
54         return (E) augmentation.get(augmentationType);
55     }
56
57      
58     public TestResultsBuilder setTestResult(final List<TestResult> value) {
59         this._testResult = value;
60         return this;
61     }
62     
63     public TestResultsBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults> augmentation) {
64         if (augmentation == null) {
65             return removeAugmentation(augmentationType);
66         }
67     
68         if (!(this.augmentation instanceof HashMap)) {
69             this.augmentation = new HashMap<>();
70         }
71     
72         this.augmentation.put(augmentationType, augmentation);
73         return this;
74     }
75     
76     public TestResultsBuilder removeAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> augmentationType) {
77         if (this.augmentation instanceof HashMap) {
78             this.augmentation.remove(augmentationType);
79         }
80         return this;
81     }
82
83     @Override
84     public TestResults build() {
85         return new TestResultsImpl(this);
86     }
87
88     private static final class TestResultsImpl implements TestResults {
89
90         @Override
91         public java.lang.Class<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults> getImplementedInterface() {
92             return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults.class;
93         }
94
95         private final List<TestResult> _testResult;
96
97         private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> augmentation = Collections.emptyMap();
98
99         private TestResultsImpl(TestResultsBuilder base) {
100             this._testResult = base.getTestResult();
101             switch (base.augmentation.size()) {
102             case 0:
103                 this.augmentation = Collections.emptyMap();
104                 break;
105             case 1:
106                 final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> e = base.augmentation.entrySet().iterator().next();
107                 this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>>singletonMap(e.getKey(), e.getValue());
108                 break;
109             default :
110                 this.augmentation = new HashMap<>(base.augmentation);
111             }
112         }
113
114         @Override
115         public List<TestResult> getTestResult() {
116             return _testResult;
117         }
118         
119         @SuppressWarnings("unchecked")
120         @Override
121         public <E extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> E getAugmentation(java.lang.Class<E> augmentationType) {
122             if (augmentationType == null) {
123                 throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
124             }
125             return (E) augmentation.get(augmentationType);
126         }
127
128         private int hash = 0;
129         private volatile boolean hashValid = false;
130         
131         @Override
132         public int hashCode() {
133             if (hashValid) {
134                 return hash;
135             }
136         
137             final int prime = 31;
138             int result = 1;
139             result = prime * result + Objects.hashCode(_testResult);
140             result = prime * result + Objects.hashCode(augmentation);
141         
142             hash = result;
143             hashValid = true;
144             return result;
145         }
146
147         @Override
148         public boolean equals(java.lang.Object obj) {
149             if (this == obj) {
150                 return true;
151             }
152             if (!(obj instanceof DataObject)) {
153                 return false;
154             }
155             if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults.class.equals(((DataObject)obj).getImplementedInterface())) {
156                 return false;
157             }
158             org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults)obj;
159             if (!Objects.equals(_testResult, other.getTestResult())) {
160                 return false;
161             }
162             if (getClass() == obj.getClass()) {
163                 // Simple case: we are comparing against self
164                 TestResultsImpl otherImpl = (TestResultsImpl) obj;
165                 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
166                     return false;
167                 }
168             } else {
169                 // Hard case: compare our augments with presence there...
170                 for (Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>>, Augmentation<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults>> e : augmentation.entrySet()) {
171                     if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
172                         return false;
173                     }
174                 }
175                 // .. and give the other one the chance to do the same
176                 if (!obj.equals(this)) {
177                     return false;
178                 }
179             }
180             return true;
181         }
182
183         @Override
184         public java.lang.String toString() {
185             java.lang.String name = "TestResults [";
186             java.lang.StringBuilder builder = new java.lang.StringBuilder (name);
187             if (_testResult != null) {
188                 builder.append("_testResult=");
189                 builder.append(_testResult);
190             }
191             final int builderLength = builder.length();
192             final int builderAdditionalLength = builder.substring(name.length(), builderLength).length();
193             if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) {
194                 builder.append(", ");
195             }
196             builder.append("augmentation=");
197             builder.append(augmentation.values());
198             return builder.append(']').toString();
199         }
200     }
201
202 }