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;
9 import java.util.Collections;
13 * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult} instances.
15 * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult
18 public class TestResultBuilder implements Builder<org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult> {
20 private TestResultKey _key;
21 private List<java.lang.String> _results;
22 private java.lang.String _testIdentifier;
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();
26 public TestResultBuilder() {
29 public TestResultBuilder(TestResult base) {
30 if (base.getKey() == null) {
31 this._key = new TestResultKey(
32 base.getTestIdentifier()
34 this._testIdentifier = base.getTestIdentifier();
36 this._key = base.getKey();
37 this._testIdentifier = _key.getTestIdentifier();
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);
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());
55 public TestResultKey getKey() {
59 public List<java.lang.String> getResults() {
63 public java.lang.String getTestIdentifier() {
64 return _testIdentifier;
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!");
72 return (E) augmentation.get(augmentationType);
76 public TestResultBuilder setKey(final TestResultKey value) {
82 public TestResultBuilder setResults(final List<java.lang.String> value) {
83 this._results = value;
88 public TestResultBuilder setTestIdentifier(final java.lang.String value) {
89 this._testIdentifier = value;
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);
98 if (!(this.augmentation instanceof HashMap)) {
99 this.augmentation = new HashMap<>();
102 this.augmentation.put(augmentationType, augmentation);
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);
114 public TestResult build() {
115 return new TestResultImpl(this);
118 private static final class TestResultImpl implements TestResult {
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;
125 private final TestResultKey _key;
126 private final List<java.lang.String> _results;
127 private final java.lang.String _testIdentifier;
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();
131 private TestResultImpl(TestResultBuilder base) {
132 if (base.getKey() == null) {
133 this._key = new TestResultKey(
134 base.getTestIdentifier()
136 this._testIdentifier = base.getTestIdentifier();
138 this._key = base.getKey();
139 this._testIdentifier = _key.getTestIdentifier();
141 this._results = base.getResults();
142 switch (base.augmentation.size()) {
144 this.augmentation = Collections.emptyMap();
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());
151 this.augmentation = new HashMap<>(base.augmentation);
156 public TestResultKey getKey() {
161 public List<java.lang.String> getResults() {
166 public java.lang.String getTestIdentifier() {
167 return _testIdentifier;
170 @SuppressWarnings("unchecked")
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!");
176 return (E) augmentation.get(augmentationType);
179 private int hash = 0;
180 private volatile boolean hashValid = false;
183 public int hashCode() {
188 final int prime = 31;
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);
201 public boolean equals(java.lang.Object obj) {
205 if (!(obj instanceof DataObject)) {
208 if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class.equals(((DataObject)obj).getImplementedInterface())) {
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())) {
215 if (!Objects.equals(_results, other.getResults())) {
218 if (!Objects.equals(_testIdentifier, other.getTestIdentifier())) {
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)) {
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()))) {
234 // .. and give the other one the chance to do the same
235 if (!obj.equals(this)) {
243 public java.lang.String toString() {
244 java.lang.String name = "TestResult [";
245 java.lang.StringBuilder builder = new java.lang.StringBuilder (name);
247 builder.append("_key=");
248 builder.append(_key);
249 builder.append(", ");
251 if (_results != null) {
252 builder.append("_results=");
253 builder.append(_results);
254 builder.append(", ");
256 if (_testIdentifier != null) {
257 builder.append("_testIdentifier=");
258 builder.append(_testIdentifier);
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(", ");
265 builder.append("augmentation=");
266 builder.append(augmentation.values());
267 return builder.append(']').toString();