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