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 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;
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;
28 public RefineHolderImpl(final String moduleName, final int line, final String name) {
29 super(moduleName, line);
30 this.targetPathString = name;
34 public String getDefaultStr() {
38 public void setDefaultStr(final String defaultStr) {
39 this.defaultStr = defaultStr;
43 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getDescription()
46 public String getDescription() {
51 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setDescription(java.lang.String)
54 public void setDescription(final String description) {
55 this.description = description;
59 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getReference()
62 public String getReference() {
67 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setReference(java.lang.String)
70 public void setReference(final String reference) {
71 this.reference = reference;
75 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isConfiguration()
78 public Boolean isConfiguration() {
83 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setConfiguration(java.lang.Boolean)
86 public void setConfiguration(final Boolean config) {
91 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isMandatory()
94 public Boolean isMandatory() {
99 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMandatory(java.lang.Boolean)
102 public void setMandatory(final Boolean mandatory) {
103 this.mandatory = mandatory;
107 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#isPresence()
110 public Boolean isPresence() {
115 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setPresence(java.lang.Boolean)
118 public void setPresence(final Boolean presence) {
119 this.presence = presence;
123 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMust()
126 public MustDefinition getMust() {
131 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMust(org.opendaylight.yangtools.yang.model.api.MustDefinition)
134 public void setMust(final MustDefinition must) {
139 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMinElements()
142 public Integer getMinElements() {
147 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMinElements(java.lang.Integer)
150 public void setMinElements(final Integer minElements) {
151 this.minElements = minElements;
155 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#getMaxElements()
158 public Integer getMaxElements() {
163 * @see org.opendaylight.yangtools.yang.parser.builder.impl.IRefineBuilder#setMaxElements(java.lang.Integer)
166 public void setMaxElements(final Integer maxElements) {
167 this.maxElements = maxElements;
171 public String toString() {
172 return "refine " + targetPathString;
176 public Status getStatus() {
177 // TODO Auto-generated method stub
182 public void setStatus(final Status status) {
183 // TODO Auto-generated method stub
188 public int hashCode() {
189 final int prime = 31;
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);
207 public boolean equals(final Object obj) {
214 if (getClass() != obj.getClass()) {
217 RefineHolderImpl other = (RefineHolderImpl) obj;
218 if (addedUnknownNodes == null) {
219 if (other.addedUnknownNodes != null) {
222 } else if (!addedUnknownNodes.equals(other.addedUnknownNodes)) {
225 if (config == null) {
226 if (other.config != null) {
229 } else if (!config.equals(other.config)) {
232 if (defaultStr == null) {
233 if (other.defaultStr != null) {
236 } else if (!defaultStr.equals(other.defaultStr)) {
239 if (description == null) {
240 if (other.description != null) {
243 } else if (!description.equals(other.description)) {
246 if (mandatory == null) {
247 if (other.mandatory != null) {
250 } else if (!mandatory.equals(other.mandatory)) {
253 if (maxElements == null) {
254 if (other.maxElements != null) {
257 } else if (!maxElements.equals(other.maxElements)) {
260 if (minElements == null) {
261 if (other.minElements != null) {
264 } else if (!minElements.equals(other.minElements)) {
268 if (other.must != null) {
271 } else if (!must.equals(other.must)) {
274 if (targetPathString == null) {
275 if (other.targetPathString != null) {
278 } else if (!targetPathString.equals(other.targetPathString)) {
281 if (getParent() == null) {
282 if (other.getParent() != null) {
285 } else if (!getParent().equals(other.getParent())) {
288 if (presence == null) {
289 if (other.presence != null) {
292 } else if (!presence.equals(other.presence)) {
295 if (reference == null) {
296 if (other.reference != null) {
299 } else if (!reference.equals(other.reference)) {
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
317 public String getTargetPathString() {
318 return targetPathString;