A great update on the alto-commons implementation.
[alto.git] / alto-provider / src / main / yang-gen-sal / org / opendaylight / yang / gen / v1 / urn / opendaylight / params / xml / ns / yang / controller / config / alto / provider / impl / rev141119 / modules / module / configuration / alto / provider / impl / RpcRegistryBuilder.java
1 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl;
2 import java.util.Collections;
3 import java.util.Map;
4 import org.opendaylight.yangtools.yang.binding.DataObject;
5 import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
6 import java.util.HashMap;
7 import org.opendaylight.yangtools.concepts.Builder;
8 import org.opendaylight.yangtools.yang.binding.Augmentation;
9
10
11 /**
12  * Class that builds {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry} instances.
13  *
14  * @see org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry
15  *
16  */
17 public class RpcRegistryBuilder implements Builder <org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry> {
18
19     private java.lang.Object _name;
20     private java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> _type;
21
22     Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> augmentation = new HashMap<>();
23
24     public RpcRegistryBuilder() {
25     }
26     public RpcRegistryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef arg) {
27         this._type = arg.getType();
28         this._name = arg.getName();
29     }
30
31     public RpcRegistryBuilder(RpcRegistry base) {
32         this._name = base.getName();
33         this._type = base.getType();
34         if (base instanceof RpcRegistryImpl) {
35             RpcRegistryImpl impl = (RpcRegistryImpl) base;
36             this.augmentation = new HashMap<>(impl.augmentation);
37         } else if (base instanceof AugmentationHolder) {
38             @SuppressWarnings("unchecked")
39             AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>) base;
40             this.augmentation = new HashMap<>(casted.augmentations());
41         }
42     }
43
44     /**
45      *Set fields from given grouping argument. Valid argument is instance of one of following types:
46      * <ul>
47      * <li>org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef</li>
48      * </ul>
49      *
50      * @param arg grouping object
51      * @throws IllegalArgumentException if given argument is none of valid types
52     */
53     public void fieldsFrom(DataObject arg) {
54         boolean isValidArg = false;
55         if (arg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef) {
56             this._type = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef)arg).getType();
57             this._name = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef)arg).getName();
58             isValidArg = true;
59         }
60         if (!isValidArg) {
61             throw new IllegalArgumentException(
62               "expected one of: [org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceRef] \n" +
63               "but was: " + arg
64             );
65         }
66     }
67
68     public java.lang.Object getName() {
69         return _name;
70     }
71     
72     public java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> getType() {
73         return _type;
74     }
75     
76     @SuppressWarnings("unchecked")
77     public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> E getAugmentation(java.lang.Class<E> augmentationType) {
78         if (augmentationType == null) {
79             throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
80         }
81         return (E) augmentation.get(augmentationType);
82     }
83
84     public RpcRegistryBuilder setName(java.lang.Object value) {
85         this._name = value;
86         return this;
87     }
88     
89     public RpcRegistryBuilder setType(java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> value) {
90         this._type = value;
91         return this;
92     }
93     
94     public RpcRegistryBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry> augmentation) {
95         if (augmentation == null) {
96             return removeAugmentation(augmentationType);
97         }
98         this.augmentation.put(augmentationType, augmentation);
99         return this;
100     }
101     
102     public RpcRegistryBuilder removeAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> augmentationType) {
103         this.augmentation.remove(augmentationType);
104         return this;
105     }
106
107     public RpcRegistry build() {
108         return new RpcRegistryImpl(this);
109     }
110
111     private static final class RpcRegistryImpl implements RpcRegistry {
112
113         public java.lang.Class<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry> getImplementedInterface() {
114             return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry.class;
115         }
116
117         private final java.lang.Object _name;
118         private final java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> _type;
119
120         private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> augmentation = new HashMap<>();
121
122         private RpcRegistryImpl(RpcRegistryBuilder base) {
123             this._name = base.getName();
124             this._type = base.getType();
125             switch (base.augmentation.size()) {
126             case 0:
127                 this.augmentation = Collections.emptyMap();
128                 break;
129                 case 1:
130                     final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> e = base.augmentation.entrySet().iterator().next();
131                     this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>singletonMap(e.getKey(), e.getValue());
132                 break;
133             default :
134                 this.augmentation = new HashMap<>(base.augmentation);
135             }
136         }
137
138         @Override
139         public java.lang.Object getName() {
140             return _name;
141         }
142         
143         @Override
144         public java.lang.Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServiceType> getType() {
145             return _type;
146         }
147         
148         @SuppressWarnings("unchecked")
149         @Override
150         public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> E getAugmentation(java.lang.Class<E> augmentationType) {
151             if (augmentationType == null) {
152                 throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!");
153             }
154             return (E) augmentation.get(augmentationType);
155         }
156
157         @Override
158         public int hashCode() {
159             final int prime = 31;
160             int result = 1;
161             result = prime * result + ((_name == null) ? 0 : _name.hashCode());
162             result = prime * result + ((_type == null) ? 0 : _type.hashCode());
163             result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode());
164             return result;
165         }
166
167         @Override
168         public boolean equals(java.lang.Object obj) {
169             if (this == obj) {
170                 return true;
171             }
172             if (!(obj instanceof DataObject)) {
173                 return false;
174             }
175             if (!org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry.class.equals(((DataObject)obj).getImplementedInterface())) {
176                 return false;
177             }
178             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry other = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry)obj;
179             if (_name == null) {
180                 if (other.getName() != null) {
181                     return false;
182                 }
183             } else if(!_name.equals(other.getName())) {
184                 return false;
185             }
186             if (_type == null) {
187                 if (other.getType() != null) {
188                     return false;
189                 }
190             } else if(!_type.equals(other.getType())) {
191                 return false;
192             }
193             if (getClass() == obj.getClass()) {
194                 // Simple case: we are comparing against self
195                 RpcRegistryImpl otherImpl = (RpcRegistryImpl) obj;
196                 if (augmentation == null) {
197                     if (otherImpl.augmentation != null) {
198                         return false;
199                     }
200                 } else if(!augmentation.equals(otherImpl.augmentation)) {
201                     return false;
202                 }
203             } else {
204                 // Hard case: compare our augments with presence there...
205                 for (Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.configuration.alto.provider.impl.RpcRegistry>> e : augmentation.entrySet()) {
206                     if (!e.getValue().equals(other.getAugmentation(e.getKey()))) {
207                         return false;
208                     }
209                 }
210                 // .. and give the other one the chance to do the same
211                 if (!obj.equals(this)) {
212                     return false;
213                 }
214             }
215             return true;
216         }
217
218         @Override
219         public java.lang.String toString() {
220             java.lang.StringBuilder builder = new java.lang.StringBuilder ("RpcRegistry [");
221             boolean first = true;
222         
223             if (_name != null) {
224                 if (first) {
225                     first = false;
226                 } else {
227                     builder.append(", ");
228                 }
229                 builder.append("_name=");
230                 builder.append(_name);
231              }
232             if (_type != null) {
233                 if (first) {
234                     first = false;
235                 } else {
236                     builder.append(", ");
237                 }
238                 builder.append("_type=");
239                 builder.append(_type);
240              }
241             if (first) {
242                 first = false;
243             } else {
244                 builder.append(", ");
245             }
246             builder.append("augmentation=");
247             builder.append(augmentation.values());
248             return builder.append(']').toString();
249         }
250     }
251
252 }