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 Ipv6AddressBuilder} instances.
22 * @see Ipv6AddressBuilder
25 public class Ipv6AddressBuilder implements Builder<Ipv6Address> {
27 private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address _ipv6Address;
30 Map<Class<? extends Augmentation<Ipv6Address>>, Augmentation<Ipv6Address>> augmentation = Collections.emptyMap();
32 public Ipv6AddressBuilder() {
35 public Ipv6AddressBuilder(Ipv6Address base) {
36 this._ipv6Address = base.getIpv6Address();
37 if (base instanceof Ipv6AddressImpl) {
38 Ipv6AddressImpl impl = (Ipv6AddressImpl) 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<Ipv6Address>>, Augmentation<Ipv6Address>> aug =((AugmentationHolder<Ipv6Address>) 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.Ipv6Address getIpv6Address() {
56 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
57 public <E$$ extends Augmentation<Ipv6Address>> E$$ augmentation(Class<E$$> augmentationType) {
58 return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
62 public Ipv6AddressBuilder setIpv6Address(final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address value) {
63 this._ipv6Address = value;
67 public Ipv6AddressBuilder addAugmentation(Class<? extends Augmentation<Ipv6Address>> augmentationType, Augmentation<Ipv6Address> 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 Ipv6AddressBuilder removeAugmentation(Class<? extends Augmentation<Ipv6Address>> augmentationType) {
81 if (this.augmentation instanceof HashMap) {
82 this.augmentation.remove(augmentationType);
88 public Ipv6Address build() {
89 return new Ipv6AddressImpl(this);
92 private static final class Ipv6AddressImpl implements Ipv6Address {
94 private final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address _ipv6Address;
96 private Map<Class<? extends Augmentation<Ipv6Address>>, Augmentation<Ipv6Address>> augmentation = Collections.emptyMap();
98 Ipv6AddressImpl(Ipv6AddressBuilder base) {
99 this._ipv6Address = base.getIpv6Address();
100 this.augmentation = ImmutableMap.copyOf(base.augmentation);
104 public Class<Ipv6Address> getImplementedInterface() {
105 return Ipv6Address.class;
109 public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address getIpv6Address() {
113 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
115 public <E$$ extends Augmentation<Ipv6Address>> 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(_ipv6Address);
131 result = prime * result + Objects.hashCode(augmentation);
139 public boolean equals(Object obj) {
143 if (!(obj instanceof DataObject)) {
146 if (!Ipv6Address.class.equals(((DataObject)obj).getImplementedInterface())) {
149 Ipv6Address other = (Ipv6Address)obj;
150 if (!Objects.equals(_ipv6Address, other.getIpv6Address())) {
153 if (getClass() == obj.getClass()) {
154 // Simple case: we are comparing against self
155 Ipv6AddressImpl otherImpl = (Ipv6AddressImpl) obj;
156 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
160 // Hard case: compare our augments with presence there...
161 for (Map.Entry<Class<? extends Augmentation<Ipv6Address>>, Augmentation<Ipv6Address>> 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("Ipv6Address");
177 CodeHelpers.appendValue(helper, "_ipv6Address", _ipv6Address);
178 CodeHelpers.appendValue(helper, "augmentation", augmentation.values());
179 return helper.toString();