Merge "SDN-R add updated devicemanager"
[ccsdk/features.git] / sdnr / wt / devicemanager-gran / provider / src / main / java / org / opendaylight / yang / gen / v1 / urn / _3gpp / tsg / sa5 / nrm / types / rev180731 / guami / AmfIdBuilder.java
1 package org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.guami;
2 import com.google.common.base.MoreObjects;
3 import com.google.common.collect.ImmutableMap;
4 import java.lang.Class;
5 import java.lang.Object;
6 import java.lang.Override;
7 import java.lang.String;
8 import java.lang.SuppressWarnings;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.Map;
12 import java.util.Objects;
13 import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.TAMFPointer;
14 import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.TAMFRegionId;
15 import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.TAMFSetId;
16 import org.opendaylight.yangtools.concepts.Builder;
17 import org.opendaylight.yangtools.yang.binding.Augmentation;
18 import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
19 import org.opendaylight.yangtools.yang.binding.CodeHelpers;
20 import org.opendaylight.yangtools.yang.binding.DataObject;
21
22 /**
23  * Class that builds {@link AmfIdBuilder} instances.
24  *
25  * @see AmfIdBuilder
26  *
27  */
28 public class AmfIdBuilder implements Builder<AmfId> {
29
30     private TAMFPointer _aMFPointer;
31     private TAMFRegionId _aMFRegionId;
32     private TAMFSetId _aMFSetId;
33
34
35     Map<Class<? extends Augmentation<AmfId>>, Augmentation<AmfId>> augmentation = Collections.emptyMap();
36
37     public AmfIdBuilder() {
38     }
39     public AmfIdBuilder(org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier arg) {
40         this._aMFRegionId = arg.getAMFRegionId();
41         this._aMFSetId = arg.getAMFSetId();
42         this._aMFPointer = arg.getAMFPointer();
43     }
44
45     public AmfIdBuilder(AmfId base) {
46         this._aMFPointer = base.getAMFPointer();
47         this._aMFRegionId = base.getAMFRegionId();
48         this._aMFSetId = base.getAMFSetId();
49         if (base instanceof AmfIdImpl) {
50             AmfIdImpl impl = (AmfIdImpl) base;
51             if (!impl.augmentation.isEmpty()) {
52                 this.augmentation = new HashMap<>(impl.augmentation);
53             }
54         } else if (base instanceof AugmentationHolder) {
55             @SuppressWarnings("unchecked")
56             Map<Class<? extends Augmentation<AmfId>>, Augmentation<AmfId>> aug =((AugmentationHolder<AmfId>) base).augmentations();
57             if (!aug.isEmpty()) {
58                 this.augmentation = new HashMap<>(aug);
59             }
60         }
61     }
62
63     /**
64      * Set fields from given grouping argument. Valid argument is instance of one of following types:
65      * <ul>
66      * <li>org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier</li>
67      * </ul>
68      *
69      * @param arg grouping object
70      * @throws IllegalArgumentException if given argument is none of valid types
71     */
72     public void fieldsFrom(DataObject arg) {
73         boolean isValidArg = false;
74         if (arg instanceof org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier) {
75             this._aMFRegionId = ((org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier)arg).getAMFRegionId();
76             this._aMFSetId = ((org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier)arg).getAMFSetId();
77             this._aMFPointer = ((org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier)arg).getAMFPointer();
78             isValidArg = true;
79         }
80         CodeHelpers.validValue(isValidArg, arg, "[org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.AMFIdentifier]");
81     }
82
83     public TAMFPointer getAMFPointer() {
84         return _aMFPointer;
85     }
86     
87     public TAMFRegionId getAMFRegionId() {
88         return _aMFRegionId;
89     }
90     
91     public TAMFSetId getAMFSetId() {
92         return _aMFSetId;
93     }
94     
95     @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
96     public <E$$ extends Augmentation<AmfId>> E$$ augmentation(Class<E$$> augmentationType) {
97         return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
98     }
99
100     
101     public AmfIdBuilder setAMFPointer(final TAMFPointer value) {
102         this._aMFPointer = value;
103         return this;
104     }
105     
106     public AmfIdBuilder setAMFRegionId(final TAMFRegionId value) {
107         this._aMFRegionId = value;
108         return this;
109     }
110     
111     public AmfIdBuilder setAMFSetId(final TAMFSetId value) {
112         this._aMFSetId = value;
113         return this;
114     }
115     
116     public AmfIdBuilder addAugmentation(Class<? extends Augmentation<AmfId>> augmentationType, Augmentation<AmfId> augmentationValue) {
117         if (augmentationValue == null) {
118             return removeAugmentation(augmentationType);
119         }
120     
121         if (!(this.augmentation instanceof HashMap)) {
122             this.augmentation = new HashMap<>();
123         }
124     
125         this.augmentation.put(augmentationType, augmentationValue);
126         return this;
127     }
128     
129     public AmfIdBuilder removeAugmentation(Class<? extends Augmentation<AmfId>> augmentationType) {
130         if (this.augmentation instanceof HashMap) {
131             this.augmentation.remove(augmentationType);
132         }
133         return this;
134     }
135
136     @Override
137     public AmfId build() {
138         return new AmfIdImpl(this);
139     }
140
141     private static final class AmfIdImpl implements AmfId {
142     
143         private final TAMFPointer _aMFPointer;
144         private final TAMFRegionId _aMFRegionId;
145         private final TAMFSetId _aMFSetId;
146     
147         private Map<Class<? extends Augmentation<AmfId>>, Augmentation<AmfId>> augmentation = Collections.emptyMap();
148     
149         AmfIdImpl(AmfIdBuilder base) {
150             this._aMFPointer = base.getAMFPointer();
151             this._aMFRegionId = base.getAMFRegionId();
152             this._aMFSetId = base.getAMFSetId();
153             this.augmentation = ImmutableMap.copyOf(base.augmentation);
154         }
155     
156         @Override
157         public Class<AmfId> getImplementedInterface() {
158             return AmfId.class;
159         }
160     
161         @Override
162         public TAMFPointer getAMFPointer() {
163             return _aMFPointer;
164         }
165         
166         @Override
167         public TAMFRegionId getAMFRegionId() {
168             return _aMFRegionId;
169         }
170         
171         @Override
172         public TAMFSetId getAMFSetId() {
173             return _aMFSetId;
174         }
175         
176         @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
177         @Override
178         public <E$$ extends Augmentation<AmfId>> E$$ augmentation(Class<E$$> augmentationType) {
179             return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
180         }
181     
182         private int hash = 0;
183         private volatile boolean hashValid = false;
184         
185         @Override
186         public int hashCode() {
187             if (hashValid) {
188                 return hash;
189             }
190         
191             final int prime = 31;
192             int result = 1;
193             result = prime * result + Objects.hashCode(_aMFPointer);
194             result = prime * result + Objects.hashCode(_aMFRegionId);
195             result = prime * result + Objects.hashCode(_aMFSetId);
196             result = prime * result + Objects.hashCode(augmentation);
197         
198             hash = result;
199             hashValid = true;
200             return result;
201         }
202     
203         @Override
204         public boolean equals(Object obj) {
205             if (this == obj) {
206                 return true;
207             }
208             if (!(obj instanceof DataObject)) {
209                 return false;
210             }
211             if (!AmfId.class.equals(((DataObject)obj).getImplementedInterface())) {
212                 return false;
213             }
214             AmfId other = (AmfId)obj;
215             if (!Objects.equals(_aMFPointer, other.getAMFPointer())) {
216                 return false;
217             }
218             if (!Objects.equals(_aMFRegionId, other.getAMFRegionId())) {
219                 return false;
220             }
221             if (!Objects.equals(_aMFSetId, other.getAMFSetId())) {
222                 return false;
223             }
224             if (getClass() == obj.getClass()) {
225                 // Simple case: we are comparing against self
226                 AmfIdImpl otherImpl = (AmfIdImpl) obj;
227                 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
228                     return false;
229                 }
230             } else {
231                 // Hard case: compare our augments with presence there...
232                 for (Map.Entry<Class<? extends Augmentation<AmfId>>, Augmentation<AmfId>> e : augmentation.entrySet()) {
233                     if (!e.getValue().equals(other.augmentation(e.getKey()))) {
234                         return false;
235                     }
236                 }
237                 // .. and give the other one the chance to do the same
238                 if (!obj.equals(this)) {
239                     return false;
240                 }
241             }
242             return true;
243         }
244     
245         @Override
246         public String toString() {
247             final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("AmfId");
248             CodeHelpers.appendValue(helper, "_aMFPointer", _aMFPointer);
249             CodeHelpers.appendValue(helper, "_aMFRegionId", _aMFRegionId);
250             CodeHelpers.appendValue(helper, "_aMFSetId", _aMFSetId);
251             CodeHelpers.appendValue(helper, "augmentation", augmentation.values());
252             return helper.toString();
253         }
254     }
255 }