1 package org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice;
2 import org.opendaylight.yangtools.yang.binding.Augmentation;
3 import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
4 import org.opendaylight.yangtools.yang.binding.TreeNode;
5 import java.util.HashMap;
6 import org.opendaylight.yangtools.concepts.Builder;
7 import java.util.Objects;
8 import java.util.Collections;
13 * Class that builds {@link org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A} instances.
15 * @see org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A
18 public class ABuilder implements Builder <org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A> {
20 private java.lang.String _case1;
22 Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>>, Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> augmentation = Collections.emptyMap();
27 public ABuilder(A base) {
28 this._case1 = base.getCase1();
29 if (base instanceof AImpl) {
30 AImpl impl = (AImpl) base;
31 if (!impl.augmentation.isEmpty()) {
32 this.augmentation = new HashMap<>(impl.augmentation);
34 } else if (base instanceof AugmentationHolder) {
35 @SuppressWarnings("unchecked")
36 AugmentationHolder<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>) base;
37 if (!casted.augmentations().isEmpty()) {
38 this.augmentation = new HashMap<>(casted.augmentations());
44 public java.lang.String getCase1() {
48 @SuppressWarnings("unchecked")
49 public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> E getAugmentation(java.lang.Class<E> augmentationType) {
50 if (augmentationType == null) {
51 throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
53 return (E) augmentation.get(augmentationType);
57 public ABuilder setCase1(final java.lang.String value) {
62 public ABuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A> augmentation) {
63 if (augmentation == null) {
64 return removeAugmentation(augmentationType);
67 if (!(this.augmentation instanceof HashMap)) {
68 this.augmentation = new HashMap<>();
71 this.augmentation.put(augmentationType, augmentation);
75 public ABuilder removeAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> augmentationType) {
76 if (this.augmentation instanceof HashMap) {
77 this.augmentation.remove(augmentationType);
83 return new AImpl(this);
86 private static final class AImpl implements A {
88 public java.lang.Class<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A> implementedInterface() {
89 return org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A.class;
92 private final java.lang.String _case1;
94 private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>>, Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> augmentation = Collections.emptyMap();
96 private AImpl(ABuilder base) {
97 this._case1 = base.getCase1();
98 switch (base.augmentation.size()) {
100 this.augmentation = Collections.emptyMap();
103 final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>>, Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> e = base.augmentation.entrySet().iterator().next();
104 this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>>, Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>>singletonMap(e.getKey(), e.getValue());
107 this.augmentation = new HashMap<>(base.augmentation);
112 public java.lang.String getCase1() {
116 @SuppressWarnings("unchecked")
118 public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> E getAugmentation(java.lang.Class<E> augmentationType) {
119 if (augmentationType == null) {
120 throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
122 return (E) augmentation.get(augmentationType);
125 private int hash = 0;
126 private volatile boolean hashValid = false;
129 public int hashCode() {
134 final int prime = 31;
136 result = prime * result + Objects.hashCode(_case1);
137 result = prime * result + Objects.hashCode(augmentation);
145 public boolean equals(java.lang.Object obj) {
149 if (!(obj instanceof TreeNode)) {
152 if (!org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A.class.equals(((TreeNode)obj).implementedInterface())) {
155 org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A other = (org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A)obj;
156 if (!Objects.equals(_case1, other.getCase1())) {
159 if (getClass() == obj.getClass()) {
160 // Simple case: we are comparing against self
161 AImpl otherImpl = (AImpl) obj;
162 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
166 // Hard case: compare our augments with presence there...
167 for (Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>>, Augmentation<org.opendaylight.yang.gen.v1.urn.test.mainyangtest.grp.main.group.main.group.cont.main.group.cont.choice.A>> e : augmentation.entrySet()) {
168 if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
172 // .. and give the other one the chance to do the same
173 if (!obj.equals(this)) {
181 public java.lang.String toString() {
182 java.lang.StringBuilder builder = new java.lang.StringBuilder ("A [");
183 boolean first = true;
185 if (_case1 != null) {
189 builder.append(", ");
191 builder.append("_case1=");
192 builder.append(_case1);
197 builder.append(", ");
199 builder.append("augmentation=");
200 builder.append(augmentation.values());
201 return builder.append(']').toString();