1 package org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.types.rev180731.ipendpoint.address;
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.yangtools.concepts.Builder;
14 import org.opendaylight.yangtools.yang.binding.Augmentation;
15 import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
16 import org.opendaylight.yangtools.yang.binding.CodeHelpers;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
20 * Class that builds {@link Ipv6PrefixBuilder} instances.
22 * @see Ipv6PrefixBuilder
25 public class Ipv6PrefixBuilder implements Builder<Ipv6Prefix> {
27 private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix _ipv6Prefix;
30 Map<Class<? extends Augmentation<Ipv6Prefix>>, Augmentation<Ipv6Prefix>> augmentation = Collections.emptyMap();
32 public Ipv6PrefixBuilder() {
35 public Ipv6PrefixBuilder(Ipv6Prefix base) {
36 this._ipv6Prefix = base.getIpv6Prefix();
37 if (base instanceof Ipv6PrefixImpl) {
38 Ipv6PrefixImpl impl = (Ipv6PrefixImpl) base;
39 if (!impl.augmentation.isEmpty()) {
40 this.augmentation = new HashMap<>(impl.augmentation);
42 } else if (base instanceof AugmentationHolder) {
43 @SuppressWarnings("unchecked")
44 Map<Class<? extends Augmentation<Ipv6Prefix>>, Augmentation<Ipv6Prefix>> aug =((AugmentationHolder<Ipv6Prefix>) base).augmentations();
46 this.augmentation = new HashMap<>(aug);
52 public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix getIpv6Prefix() {
56 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
57 public <E$$ extends Augmentation<Ipv6Prefix>> E$$ augmentation(Class<E$$> augmentationType) {
58 return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
62 public Ipv6PrefixBuilder setIpv6Prefix(final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix value) {
63 this._ipv6Prefix = value;
67 public Ipv6PrefixBuilder addAugmentation(Class<? extends Augmentation<Ipv6Prefix>> augmentationType, Augmentation<Ipv6Prefix> augmentationValue) {
68 if (augmentationValue == null) {
69 return removeAugmentation(augmentationType);
72 if (!(this.augmentation instanceof HashMap)) {
73 this.augmentation = new HashMap<>();
76 this.augmentation.put(augmentationType, augmentationValue);
80 public Ipv6PrefixBuilder removeAugmentation(Class<? extends Augmentation<Ipv6Prefix>> augmentationType) {
81 if (this.augmentation instanceof HashMap) {
82 this.augmentation.remove(augmentationType);
88 public Ipv6Prefix build() {
89 return new Ipv6PrefixImpl(this);
92 private static final class Ipv6PrefixImpl implements Ipv6Prefix {
94 private final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix _ipv6Prefix;
96 private Map<Class<? extends Augmentation<Ipv6Prefix>>, Augmentation<Ipv6Prefix>> augmentation = Collections.emptyMap();
98 Ipv6PrefixImpl(Ipv6PrefixBuilder base) {
99 this._ipv6Prefix = base.getIpv6Prefix();
100 this.augmentation = ImmutableMap.copyOf(base.augmentation);
104 public Class<Ipv6Prefix> getImplementedInterface() {
105 return Ipv6Prefix.class;
109 public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix getIpv6Prefix() {
113 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
115 public <E$$ extends Augmentation<Ipv6Prefix>> E$$ augmentation(Class<E$$> augmentationType) {
116 return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
119 private int hash = 0;
120 private volatile boolean hashValid = false;
123 public int hashCode() {
128 final int prime = 31;
130 result = prime * result + Objects.hashCode(_ipv6Prefix);
131 result = prime * result + Objects.hashCode(augmentation);
139 public boolean equals(Object obj) {
143 if (!(obj instanceof DataObject)) {
146 if (!Ipv6Prefix.class.equals(((DataObject)obj).getImplementedInterface())) {
149 Ipv6Prefix other = (Ipv6Prefix)obj;
150 if (!Objects.equals(_ipv6Prefix, other.getIpv6Prefix())) {
153 if (getClass() == obj.getClass()) {
154 // Simple case: we are comparing against self
155 Ipv6PrefixImpl otherImpl = (Ipv6PrefixImpl) obj;
156 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
160 // Hard case: compare our augments with presence there...
161 for (Map.Entry<Class<? extends Augmentation<Ipv6Prefix>>, Augmentation<Ipv6Prefix>> e : augmentation.entrySet()) {
162 if (!e.getValue().equals(other.augmentation(e.getKey()))) {
166 // .. and give the other one the chance to do the same
167 if (!obj.equals(this)) {
175 public String toString() {
176 final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("Ipv6Prefix");
177 CodeHelpers.appendValue(helper, "_ipv6Prefix", _ipv6Prefix);
178 CodeHelpers.appendValue(helper, "augmentation", augmentation.values());
179 return helper.toString();