dc217958ce9b639abe4dbaeaf78ac453fb68db41
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / RefineHolderImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.parser.builder.impl;
9
10 import java.util.Objects;
11 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
12 import org.opendaylight.yangtools.yang.model.api.Status;
13 import org.opendaylight.yangtools.yang.parser.builder.api.RefineBuilder;
14 import org.opendaylight.yangtools.yang.parser.builder.util.AbstractBuilder;
15
16 public final class RefineHolderImpl extends AbstractBuilder implements RefineBuilder {
17     private final String targetPathString;
18     private String defaultStr;
19     private String description;
20     private String reference;
21     private Boolean config;
22     private Boolean mandatory;
23     private Boolean presence;
24     private MustDefinition must;
25     private Integer minElements;
26     private Integer maxElements;
27
28     public RefineHolderImpl(final String moduleName, final int line, final String name) {
29         super(moduleName, line);
30         this.targetPathString = name;
31     }
32
33     @Override
34     public String getDefaultStr() {
35         return defaultStr;
36     }
37
38     public void setDefaultStr(final String defaultStr) {
39         this.defaultStr = defaultStr;
40     }
41
42     /* (non-Javadoc)
43      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getDescription()
44      */
45     @Override
46     public String getDescription() {
47         return description;
48     }
49
50     /* (non-Javadoc)
51      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setDescription(java.lang.String)
52      */
53     @Override
54     public void setDescription(final String description) {
55         this.description = description;
56     }
57
58     /* (non-Javadoc)
59      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getReference()
60      */
61     @Override
62     public String getReference() {
63         return reference;
64     }
65
66     /* (non-Javadoc)
67      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setReference(java.lang.String)
68      */
69     @Override
70     public void setReference(final String reference) {
71         this.reference = reference;
72     }
73
74     /* (non-Javadoc)
75      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isConfiguration()
76      */
77     @Override
78     public Boolean isConfiguration() {
79         return config;
80     }
81
82     /* (non-Javadoc)
83      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setConfiguration(java.lang.Boolean)
84      */
85     @Override
86     public void setConfiguration(final Boolean config) {
87         this.config = config;
88     }
89
90     /* (non-Javadoc)
91      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isMandatory()
92      */
93     @Override
94     public Boolean isMandatory() {
95         return mandatory;
96     }
97
98     /* (non-Javadoc)
99      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMandatory(java.lang.Boolean)
100      */
101     @Override
102     public void setMandatory(final Boolean mandatory) {
103         this.mandatory = mandatory;
104     }
105
106     /* (non-Javadoc)
107      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isPresence()
108      */
109     @Override
110     public Boolean isPresence() {
111         return presence;
112     }
113
114     /* (non-Javadoc)
115      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setPresence(java.lang.Boolean)
116      */
117     @Override
118     public void setPresence(final Boolean presence) {
119         this.presence = presence;
120     }
121
122     /* (non-Javadoc)
123      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMust()
124      */
125     @Override
126     public MustDefinition getMust() {
127         return must;
128     }
129
130     /* (non-Javadoc)
131      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMust(org.opendaylight.yangtools.yang.model.api.MustDefinition)
132      */
133     @Override
134     public void setMust(final MustDefinition must) {
135         this.must = must;
136     }
137
138     /* (non-Javadoc)
139      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMinElements()
140      */
141     @Override
142     public Integer getMinElements() {
143         return minElements;
144     }
145
146     /* (non-Javadoc)
147      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMinElements(java.lang.Integer)
148      */
149     @Override
150     public void setMinElements(final Integer minElements) {
151         this.minElements = minElements;
152     }
153
154     /* (non-Javadoc)
155      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMaxElements()
156      */
157     @Override
158     public Integer getMaxElements() {
159         return maxElements;
160     }
161
162     /* (non-Javadoc)
163      * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMaxElements(java.lang.Integer)
164      */
165     @Override
166     public void setMaxElements(final Integer maxElements) {
167         this.maxElements = maxElements;
168     }
169
170     @Override
171     public String toString() {
172         return "refine " + targetPathString;
173     }
174
175     @Override
176     public Status getStatus() {
177         // TODO Auto-generated method stub
178         return null;
179     }
180
181     @Override
182     public void setStatus(final Status status) {
183         // TODO Auto-generated method stub
184
185     }
186
187     @Override
188     public int hashCode() {
189         final int prime = 31;
190         int result = 1;
191         result = prime * result + Objects.hashCode(addedUnknownNodes);
192         result = prime * result + Objects.hashCode(config);
193         result = prime * result + Objects.hashCode(defaultStr);
194         result = prime * result + Objects.hashCode(description);
195         result = prime * result + Objects.hashCode(mandatory);
196         result = prime * result + Objects.hashCode(maxElements);
197         result = prime * result + Objects.hashCode(minElements);
198         result = prime * result + Objects.hashCode(must);
199         result = prime * result + Objects.hashCode(targetPathString);
200         result = prime * result + Objects.hashCode(getParent());
201         result = prime * result + Objects.hashCode(presence);
202         result = prime * result + Objects.hashCode(reference);
203         return result;
204     }
205
206     @Override
207     public boolean equals(final Object obj) {
208         if (this == obj) {
209             return true;
210         }
211         if (obj == null) {
212             return false;
213         }
214         if (getClass() != obj.getClass()) {
215             return false;
216         }
217         RefineHolderImpl other = (RefineHolderImpl) obj;
218         if (addedUnknownNodes == null) {
219             if (other.addedUnknownNodes != null) {
220                 return false;
221             }
222         } else if (!addedUnknownNodes.equals(other.addedUnknownNodes)) {
223             return false;
224         }
225         if (config == null) {
226             if (other.config != null) {
227                 return false;
228             }
229         } else if (!config.equals(other.config)) {
230             return false;
231         }
232         if (defaultStr == null) {
233             if (other.defaultStr != null) {
234                 return false;
235             }
236         } else if (!defaultStr.equals(other.defaultStr)) {
237             return false;
238         }
239         if (description == null) {
240             if (other.description != null) {
241                 return false;
242             }
243         } else if (!description.equals(other.description)) {
244             return false;
245         }
246         if (mandatory == null) {
247             if (other.mandatory != null) {
248                 return false;
249             }
250         } else if (!mandatory.equals(other.mandatory)) {
251             return false;
252         }
253         if (maxElements == null) {
254             if (other.maxElements != null) {
255                 return false;
256             }
257         } else if (!maxElements.equals(other.maxElements)) {
258             return false;
259         }
260         if (minElements == null) {
261             if (other.minElements != null) {
262                 return false;
263             }
264         } else if (!minElements.equals(other.minElements)) {
265             return false;
266         }
267         if (must == null) {
268             if (other.must != null) {
269                 return false;
270             }
271         } else if (!must.equals(other.must)) {
272             return false;
273         }
274         if (targetPathString == null) {
275             if (other.targetPathString != null) {
276                 return false;
277             }
278         } else if (!targetPathString.equals(other.targetPathString)) {
279             return false;
280         }
281         if (getParent() == null) {
282             if (other.getParent() != null) {
283                 return false;
284             }
285         } else if (!getParent().equals(other.getParent())) {
286             return false;
287         }
288         if (presence == null) {
289             if (other.presence != null) {
290                 return false;
291             }
292         } else if (!presence.equals(other.presence)) {
293             return false;
294         }
295         if (reference == null) {
296             if (other.reference != null) {
297                 return false;
298             }
299         } else if (!reference.equals(other.reference)) {
300             return false;
301         }
302         return true;
303     }
304
305
306
307     @Override
308     public Object build() {
309         // FIXME: Currently RefineBuilder.build() is not used
310         // build should returned refined element, so
311         // whole refine process is encapsulated in this refinement
312         // statement.
313         return null;
314     }
315
316     @Override
317     public String getTargetPathString() {
318         return targetPathString;
319     }
320
321 }