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