2abed8b15f7f5e6b4b6055b4dcab6f69d1e9ffd5
[ccsdk/features.git] /
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;
11 import java.util.Map;
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;
19
20 /**
21  * Class that builds {@link EndpointFqdnBuilder} instances.
22  *
23  * @see EndpointFqdnBuilder
24  *
25  */
26 public class EndpointFqdnBuilder implements Builder<EndpointFqdn> {
27
28     private DomainName _endpointFqdn;
29
30
31     Map<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> augmentation = Collections.emptyMap();
32
33     public EndpointFqdnBuilder() {
34     }
35
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);
42             }
43         } else if (base instanceof AugmentationHolder) {
44             @SuppressWarnings("unchecked")
45             Map<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> aug =((AugmentationHolder<EndpointFqdn>) base).augmentations();
46             if (!aug.isEmpty()) {
47                 this.augmentation = new HashMap<>(aug);
48             }
49         }
50     }
51
52
53     public DomainName getEndpointFqdn() {
54         return _endpointFqdn;
55     }
56     
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"));
60     }
61
62     
63     public EndpointFqdnBuilder setEndpointFqdn(final DomainName value) {
64         this._endpointFqdn = value;
65         return this;
66     }
67     
68     public EndpointFqdnBuilder addAugmentation(Class<? extends Augmentation<EndpointFqdn>> augmentationType, Augmentation<EndpointFqdn> augmentationValue) {
69         if (augmentationValue == null) {
70             return removeAugmentation(augmentationType);
71         }
72     
73         if (!(this.augmentation instanceof HashMap)) {
74             this.augmentation = new HashMap<>();
75         }
76     
77         this.augmentation.put(augmentationType, augmentationValue);
78         return this;
79     }
80     
81     public EndpointFqdnBuilder removeAugmentation(Class<? extends Augmentation<EndpointFqdn>> augmentationType) {
82         if (this.augmentation instanceof HashMap) {
83             this.augmentation.remove(augmentationType);
84         }
85         return this;
86     }
87
88     @Override
89     public EndpointFqdn build() {
90         return new EndpointFqdnImpl(this);
91     }
92
93     private static final class EndpointFqdnImpl implements EndpointFqdn {
94     
95         private final DomainName _endpointFqdn;
96     
97         private Map<Class<? extends Augmentation<EndpointFqdn>>, Augmentation<EndpointFqdn>> augmentation = Collections.emptyMap();
98     
99         EndpointFqdnImpl(EndpointFqdnBuilder base) {
100             this._endpointFqdn = base.getEndpointFqdn();
101             this.augmentation = ImmutableMap.copyOf(base.augmentation);
102         }
103     
104         @Override
105         public Class<EndpointFqdn> getImplementedInterface() {
106             return EndpointFqdn.class;
107         }
108     
109         @Override
110         public DomainName getEndpointFqdn() {
111             return _endpointFqdn;
112         }
113         
114         @SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
115         @Override
116         public <E$$ extends Augmentation<EndpointFqdn>> E$$ augmentation(Class<E$$> augmentationType) {
117             return (E$$) augmentation.get(CodeHelpers.nonNullValue(augmentationType, "augmentationType"));
118         }
119     
120         private int hash = 0;
121         private volatile boolean hashValid = false;
122         
123         @Override
124         public int hashCode() {
125             if (hashValid) {
126                 return hash;
127             }
128         
129             final int prime = 31;
130             int result = 1;
131             result = prime * result + Objects.hashCode(_endpointFqdn);
132             result = prime * result + Objects.hashCode(augmentation);
133         
134             hash = result;
135             hashValid = true;
136             return result;
137         }
138     
139         @Override
140         public boolean equals(Object obj) {
141             if (this == obj) {
142                 return true;
143             }
144             if (!(obj instanceof DataObject)) {
145                 return false;
146             }
147             if (!EndpointFqdn.class.equals(((DataObject)obj).getImplementedInterface())) {
148                 return false;
149             }
150             EndpointFqdn other = (EndpointFqdn)obj;
151             if (!Objects.equals(_endpointFqdn, other.getEndpointFqdn())) {
152                 return false;
153             }
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)) {
158                     return false;
159                 }
160             } else {
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()))) {
164                         return false;
165                     }
166                 }
167                 // .. and give the other one the chance to do the same
168                 if (!obj.equals(this)) {
169                     return false;
170                 }
171             }
172             return true;
173         }
174     
175         @Override
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();
181         }
182     }
183 }