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;
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;
22 * Class that builds {@link PlmnIdBuilder} instances.
27 public class PlmnIdBuilder implements Builder<PlmnId> {
33 Map<Class<? extends Augmentation<PlmnId>>, Augmentation<PlmnId>> augmentation = Collections.emptyMap();
35 public PlmnIdBuilder() {
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();
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);
50 } else if (base instanceof AugmentationHolder) {
51 @SuppressWarnings("unchecked")
52 Map<Class<? extends Augmentation<PlmnId>>, Augmentation<PlmnId>> aug =((AugmentationHolder<PlmnId>) base).augmentations();
54 this.augmentation = new HashMap<>(aug);
60 * Set fields from given grouping argument. Valid argument is instance of one of following types:
62 * <li>org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.PLMNId</li>
65 * @param arg grouping object
66 * @throws IllegalArgumentException if given argument is none of valid types
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();
75 CodeHelpers.validValue(isValidArg, arg, "[org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.PLMNId]");
78 public TMcc getMCC() {
82 public TMnc getMNC() {
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"));
92 public PlmnIdBuilder setMCC(final TMcc value) {
97 public PlmnIdBuilder setMNC(final TMnc value) {
102 public PlmnIdBuilder addAugmentation(Class<? extends Augmentation<PlmnId>> augmentationType, Augmentation<PlmnId> augmentationValue) {
103 if (augmentationValue == null) {
104 return removeAugmentation(augmentationType);
107 if (!(this.augmentation instanceof HashMap)) {
108 this.augmentation = new HashMap<>();
111 this.augmentation.put(augmentationType, augmentationValue);
115 public PlmnIdBuilder removeAugmentation(Class<? extends Augmentation<PlmnId>> augmentationType) {
116 if (this.augmentation instanceof HashMap) {
117 this.augmentation.remove(augmentationType);
123 public PlmnId build() {
124 return new PlmnIdImpl(this);
127 private static final class PlmnIdImpl implements PlmnId {
129 private final TMcc _mCC;
130 private final TMnc _mNC;
132 private Map<Class<? extends Augmentation<PlmnId>>, Augmentation<PlmnId>> augmentation = Collections.emptyMap();
134 PlmnIdImpl(PlmnIdBuilder base) {
135 this._mCC = base.getMCC();
136 this._mNC = base.getMNC();
137 this.augmentation = ImmutableMap.copyOf(base.augmentation);
141 public Class<PlmnId> getImplementedInterface() {
146 public TMcc getMCC() {
151 public TMnc getMNC() {
155 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
157 public <E$$ extends Augmentation<PlmnId>> E$$ augmentation(Class<E$$> augmentationType) {
158 return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
161 private int hash = 0;
162 private volatile boolean hashValid = false;
165 public int hashCode() {
170 final int prime = 31;
172 result = prime * result + Objects.hashCode(_mCC);
173 result = prime * result + Objects.hashCode(_mNC);
174 result = prime * result + Objects.hashCode(augmentation);
182 public boolean equals(Object obj) {
186 if (!(obj instanceof DataObject)) {
189 if (!PlmnId.class.equals(((DataObject)obj).getImplementedInterface())) {
192 PlmnId other = (PlmnId)obj;
193 if (!Objects.equals(_mCC, other.getMCC())) {
196 if (!Objects.equals(_mNC, other.getMNC())) {
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)) {
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()))) {
212 // .. and give the other one the chance to do the same
213 if (!obj.equals(this)) {
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();