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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.DomainName;
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 EndpointFqdnBuilder} instances.
23 * @see EndpointFqdnBuilder
26 public class EndpointFqdnBuilder implements Builder<EndpointFqdn> {
28 private DomainName _endpointFqdn;
31 Map<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> augmentation = Collections.emptyMap();
33 public EndpointFqdnBuilder() {
36 public EndpointFqdnBuilder(EndpointFqdn base) {
37 this._endpointFqdn = base.getEndpointFqdn();
38 if (base instanceof EndpointFqdnImpl) {
39 EndpointFqdnImpl impl = (EndpointFqdnImpl) base;
40 if (!impl.augmentation.isEmpty()) {
41 this.augmentation = new HashMap<>(impl.augmentation);
43 } else if (base instanceof AugmentationHolder) {
44 @SuppressWarnings("unchecked")
45 Map<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> aug =((AugmentationHolder<EndpointFqdn>) base).augmentations();
47 this.augmentation = new HashMap<>(aug);
53 public DomainName getEndpointFqdn() {
57 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
58 public <E$$ extends Augmentation<EndpointFqdn>> E$$ augmentation(Class<E$$> augmentationType) {
59 return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
63 public EndpointFqdnBuilder setEndpointFqdn(final DomainName value) {
64 this._endpointFqdn = value;
68 public EndpointFqdnBuilder addAugmentation(Class<? extends Augmentation<EndpointFqdn>> augmentationType, Augmentation<EndpointFqdn> augmentationValue) {
69 if (augmentationValue == null) {
70 return removeAugmentation(augmentationType);
73 if (!(this.augmentation instanceof HashMap)) {
74 this.augmentation = new HashMap<>();
77 this.augmentation.put(augmentationType, augmentationValue);
81 public EndpointFqdnBuilder removeAugmentation(Class<? extends Augmentation<EndpointFqdn>> augmentationType) {
82 if (this.augmentation instanceof HashMap) {
83 this.augmentation.remove(augmentationType);
89 public EndpointFqdn build() {
90 return new EndpointFqdnImpl(this);
93 private static final class EndpointFqdnImpl implements EndpointFqdn {
95 private final DomainName _endpointFqdn;
97 private Map<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> augmentation = Collections.emptyMap();
99 EndpointFqdnImpl(EndpointFqdnBuilder base) {
100 this._endpointFqdn = base.getEndpointFqdn();
101 this.augmentation = ImmutableMap.copyOf(base.augmentation);
105 public Class<EndpointFqdn> getImplementedInterface() {
106 return EndpointFqdn.class;
110 public DomainName getEndpointFqdn() {
111 return _endpointFqdn;
114 @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
116 public <E$$ extends Augmentation<EndpointFqdn>> E$$ augmentation(Class<E$$> augmentationType) {
117 return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
120 private int hash = 0;
121 private volatile boolean hashValid = false;
124 public int hashCode() {
129 final int prime = 31;
131 result = prime * result + Objects.hashCode(_endpointFqdn);
132 result = prime * result + Objects.hashCode(augmentation);
140 public boolean equals(Object obj) {
144 if (!(obj instanceof DataObject)) {
147 if (!EndpointFqdn.class.equals(((DataObject)obj).getImplementedInterface())) {
150 EndpointFqdn other = (EndpointFqdn)obj;
151 if (!Objects.equals(_endpointFqdn, other.getEndpointFqdn())) {
154 if (getClass() == obj.getClass()) {
155 // Simple case: we are comparing against self
156 EndpointFqdnImpl otherImpl = (EndpointFqdnImpl) obj;
157 if (!Objects.equals(augmentation, otherImpl.augmentation)) {
161 // Hard case: compare our augments with presence there...
162 for (Map.Entry<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> e : augmentation.entrySet()) {
163 if (!e.getValue().equals(other.augmentation(e.getKey()))) {
167 // .. and give the other one the chance to do the same
168 if (!obj.equals(this)) {
176 public String toString() {
177 final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("EndpointFqdn");
178 CodeHelpers.appendValue(helper, "_endpointFqdn", _endpointFqdn);
179 CodeHelpers.appendValue(helper, "augmentation", augmentation.values());
180 return helper.toString();