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.controller.yang.parser.util;
10 import java.util.ArrayList;
11 import java.util.List;
13 import org.opendaylight.controller.yang.model.api.MustDefinition;
14 import org.opendaylight.controller.yang.parser.builder.api.Builder;
15 import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
17 public final class RefineHolder implements Builder {
18 private Builder parent;
19 private final int line;
20 private final String name;
21 private String defaultStr;
22 private String description;
23 private String reference;
24 private Boolean config;
25 private Boolean mandatory;
26 private Boolean presence;
27 private MustDefinition must;
28 private Integer minElements;
29 private Integer maxElements;
30 private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
32 public RefineHolder(final int line, final String name) {
38 public int getLine() {
43 public Builder getParent() {
48 public void setParent(final Builder parent) {
52 public String getDefaultStr() {
56 public void setDefaultStr(final String defaultStr) {
57 this.defaultStr = defaultStr;
60 public String getDescription() {
64 public void setDescription(final String description) {
65 this.description = description;
68 public String getReference() {
72 public void setReference(final String reference) {
73 this.reference = reference;
76 public Boolean isConfiguration() {
80 public void setConfiguration(final Boolean config) {
84 public Boolean isMandatory() {
88 public void setMandatory(Boolean mandatory) {
89 this.mandatory = mandatory;
92 public Boolean isPresence() {
96 public void setPresence(Boolean presence) {
97 this.presence = presence;
100 public MustDefinition getMust() {
104 public void setMust(MustDefinition must) {
108 public Integer getMinElements() {
112 public void setMinElements(Integer minElements) {
113 this.minElements = minElements;
116 public Integer getMaxElements() {
120 public void setMaxElements(Integer maxElements) {
121 this.maxElements = maxElements;
124 public String getName() {
129 public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
130 return addedUnknownNodes;
134 public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
135 addedUnknownNodes.add(unknownNode);
139 public Object build() {
144 public int hashCode() {
145 final int prime = 31;
147 result = prime * result + ((addedUnknownNodes == null) ? 0 : addedUnknownNodes.hashCode());
148 result = prime * result + ((config == null) ? 0 : config.hashCode());
149 result = prime * result + ((defaultStr == null) ? 0 : defaultStr.hashCode());
150 result = prime * result + ((description == null) ? 0 : description.hashCode());
151 result = prime * result + ((mandatory == null) ? 0 : mandatory.hashCode());
152 result = prime * result + ((maxElements == null) ? 0 : maxElements.hashCode());
153 result = prime * result + ((minElements == null) ? 0 : minElements.hashCode());
154 result = prime * result + ((must == null) ? 0 : must.hashCode());
155 result = prime * result + ((name == null) ? 0 : name.hashCode());
156 result = prime * result + ((parent == null) ? 0 : parent.hashCode());
157 result = prime * result + ((presence == null) ? 0 : presence.hashCode());
158 result = prime * result + ((reference == null) ? 0 : reference.hashCode());
163 public boolean equals(Object obj) {
168 if (getClass() != obj.getClass())
170 RefineHolder other = (RefineHolder) obj;
171 if (addedUnknownNodes == null) {
172 if (other.addedUnknownNodes != null)
174 } else if (!addedUnknownNodes.equals(other.addedUnknownNodes))
176 if (config == null) {
177 if (other.config != null)
179 } else if (!config.equals(other.config))
181 if (defaultStr == null) {
182 if (other.defaultStr != null)
184 } else if (!defaultStr.equals(other.defaultStr))
186 if (description == null) {
187 if (other.description != null)
189 } else if (!description.equals(other.description))
191 if (mandatory == null) {
192 if (other.mandatory != null)
194 } else if (!mandatory.equals(other.mandatory))
196 if (maxElements == null) {
197 if (other.maxElements != null)
199 } else if (!maxElements.equals(other.maxElements))
201 if (minElements == null) {
202 if (other.minElements != null)
204 } else if (!minElements.equals(other.minElements))
207 if (other.must != null)
209 } else if (!must.equals(other.must))
212 if (other.name != null)
214 } else if (!name.equals(other.name))
216 if (parent == null) {
217 if (other.parent != null)
219 } else if (!parent.equals(other.parent))
221 if (presence == null) {
222 if (other.presence != null)
224 } else if (!presence.equals(other.presence))
226 if (reference == null) {
227 if (other.reference != null)
229 } else if (!reference.equals(other.reference))
235 public String toString() {
236 return "revine " + name;