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