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;
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;
21 * Class that builds {@link DnnUpfInfoBuilder} instances.
23 * @see DnnUpfInfoBuilder
26 public class DnnUpfInfoBuilder implements Builder<DnnUpfInfo> {
29 private DnnUpfInfoKey key;
32 Map<Class<? extends Augmentation<DnnUpfInfo>>, Augmentation<DnnUpfInfo>> augmentation = Collections.emptyMap();
34 public DnnUpfInfoBuilder() {
36 public DnnUpfInfoBuilder(org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.DnnUpfInfoItem arg) {
37 this._dnn = arg.getDnn();
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);
48 } else if (base instanceof AugmentationHolder) {
49 @SuppressWarnings("unchecked")
50 Map<Class<? extends Augmentation<DnnUpfInfo>>, Augmentation<DnnUpfInfo>> aug =((AugmentationHolder<DnnUpfInfo>) base).augmentations();
52 this.augmentation = new HashMap<>(aug);
58 * Set fields from given grouping argument. Valid argument is instance of one of following types:
60 * <li>org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.DnnUpfInfoItem</li>
63 * @param arg grouping object
64 * @throws IllegalArgumentException if given argument is none of valid types
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();
72 CodeHelpers.validValue(isValidArg, arg, "[org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.DnnUpfInfoItem]");
75 public DnnUpfInfoKey key() {
79 public TDnn getDnn() {
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"));
88 public DnnUpfInfoBuilder withKey(final DnnUpfInfoKey key) {
93 public DnnUpfInfoBuilder setDnn(final TDnn value) {
98 public DnnUpfInfoBuilder addAugmentation(Class<? extends Augmentation<DnnUpfInfo>> augmentationType, Augmentation<DnnUpfInfo> augmentationValue) {
99 if (augmentationValue == null) {
100 return removeAugmentation(augmentationType);
103 if (!(this.augmentation instanceof HashMap)) {
104 this.augmentation = new HashMap<>();
107 this.augmentation.put(augmentationType, augmentationValue);
111 public DnnUpfInfoBuilder removeAugmentation(Class<? extends Augmentation<DnnUpfInfo>> augmentationType) {
112 if (this.augmentation instanceof HashMap) {
113 this.augmentation.remove(augmentationType);
119 public DnnUpfInfo build() {
120 return new DnnUpfInfoImpl(this);
123 private static final class DnnUpfInfoImpl implements DnnUpfInfo {
125 private final TDnn _dnn;
126 private final DnnUpfInfoKey key;
128 private Map<Class<? extends Augmentation<DnnUpfInfo>>, Augmentation<DnnUpfInfo>> augmentation = Collections.emptyMap();
130 DnnUpfInfoImpl(DnnUpfInfoBuilder base) {
131 if (base.key() != null) {
132 this.key = base.key();
134 this.key = new DnnUpfInfoKey(base.getDnn());
136 this._dnn = key.getDnn();
137 this.augmentation = ImmutableMap.copyOf(base.augmentation);
141 public Class<DnnUpfInfo> getImplementedInterface() {
142 return DnnUpfInfo.class;
146 public DnnUpfInfoKey key() {
151 public TDnn getDnn() {
155 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
157 public <E$$ extends Augmentation<DnnUpfInfo>> 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(_dnn);
173 result = prime * result + Objects.hashCode(augmentation);
181 public boolean equals(Object obj) {
185 if (!(obj instanceof DataObject)) {
188 if (!DnnUpfInfo.class.equals(((DataObject)obj).getImplementedInterface())) {
191 DnnUpfInfo other = (DnnUpfInfo)obj;
192 if (!Objects.equals(_dnn, other.getDnn())) {
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)) {
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()))) {
208 // .. and give the other one the chance to do the same
209 if (!obj.equals(this)) {
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();