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