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