2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.builder.impl;
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;
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;
27 public RefineHolderImpl(final String moduleName, final int line, final String name) {
28 super(moduleName, line);
29 this.targetPathString = name;
33 public String getDefaultStr() {
37 public void setDefaultStr(final String defaultStr) {
38 this.defaultStr = defaultStr;
42 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getDescription()
45 public String getDescription() {
50 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setDescription(java.lang.String)
53 public void setDescription(final String description) {
54 this.description = description;
58 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getReference()
61 public String getReference() {
66 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setReference(java.lang.String)
69 public void setReference(final String reference) {
70 this.reference = reference;
74 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isConfiguration()
77 public Boolean isConfiguration() {
82 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setConfiguration(java.lang.Boolean)
85 public void setConfiguration(final Boolean config) {
90 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isMandatory()
93 public Boolean isMandatory() {
98 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMandatory(java.lang.Boolean)
101 public void setMandatory(final Boolean mandatory) {
102 this.mandatory = mandatory;
106 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isPresence()
109 public Boolean isPresence() {
114 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setPresence(java.lang.Boolean)
117 public void setPresence(final Boolean presence) {
118 this.presence = presence;
122 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMust()
125 public MustDefinition getMust() {
130 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMust(org.opendaylight.yangtools.yang.model.api.MustDefinition)
133 public void setMust(final MustDefinition must) {
138 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMinElements()
141 public Integer getMinElements() {
146 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMinElements(java.lang.Integer)
149 public void setMinElements(final Integer minElements) {
150 this.minElements = minElements;
154 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMaxElements()
157 public Integer getMaxElements() {
162 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMaxElements(java.lang.Integer)
165 public void setMaxElements(final Integer maxElements) {
166 this.maxElements = maxElements;
170 public String toString() {
171 return "refine " + targetPathString;
175 public Status getStatus() {
176 // TODO Auto-generated method stub
181 public void setStatus(final Status status) {
182 // TODO Auto-generated method stub
187 public int hashCode() {
188 final int prime = 31;
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());
206 public boolean equals(final Object obj) {
213 if (getClass() != obj.getClass()) {
216 RefineHolderImpl other = (RefineHolderImpl) obj;
217 if (addedUnknownNodes == null) {
218 if (other.addedUnknownNodes != null) {
221 } else if (!addedUnknownNodes.equals(other.addedUnknownNodes)) {
224 if (config == null) {
225 if (other.config != null) {
228 } else if (!config.equals(other.config)) {
231 if (defaultStr == null) {
232 if (other.defaultStr != null) {
235 } else if (!defaultStr.equals(other.defaultStr)) {
238 if (description == null) {
239 if (other.description != null) {
242 } else if (!description.equals(other.description)) {
245 if (mandatory == null) {
246 if (other.mandatory != null) {
249 } else if (!mandatory.equals(other.mandatory)) {
252 if (maxElements == null) {
253 if (other.maxElements != null) {
256 } else if (!maxElements.equals(other.maxElements)) {
259 if (minElements == null) {
260 if (other.minElements != null) {
263 } else if (!minElements.equals(other.minElements)) {
267 if (other.must != null) {
270 } else if (!must.equals(other.must)) {
273 if (targetPathString == null) {
274 if (other.targetPathString != null) {
277 } else if (!targetPathString.equals(other.targetPathString)) {
280 if (getParent() == null) {
281 if (other.getParent() != null) {
284 } else if (!getParent().equals(other.getParent())) {
287 if (presence == null) {
288 if (other.presence != null) {
291 } else if (!presence.equals(other.presence)) {
294 if (reference == null) {
295 if (other.reference != null) {
298 } else if (!reference.equals(other.reference)) {
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
316 public String getTargetPathString() {
317 return targetPathString;