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.api.ConfigNode;
16 import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
18 public final class RefineHolder implements Builder, ConfigNode {
19 private Builder parent;
20 private final int line;
21 private final String name;
22 private String defaultStr;
23 private String description;
24 private String reference;
25 private Boolean config;
26 private Boolean mandatory;
27 private Boolean presence;
28 private MustDefinition must;
29 private Integer minElements;
30 private Integer maxElements;
31 private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
33 public RefineHolder(final int line, final String name) {
39 public int getLine() {
44 public Builder getParent() {
49 public void setParent(final Builder parent) {
53 public String getDefaultStr() {
57 public void setDefaultStr(final String defaultStr) {
58 this.defaultStr = defaultStr;
61 public String getDescription() {
65 public void setDescription(final String description) {
66 this.description = description;
69 public String getReference() {
73 public void setReference(final String reference) {
74 this.reference = reference;
78 public Boolean isConfiguration() {
83 public void setConfiguration(final Boolean config) {
87 public Boolean isMandatory() {
91 public void setMandatory(Boolean mandatory) {
92 this.mandatory = mandatory;
95 public Boolean isPresence() {
99 public void setPresence(Boolean presence) {
100 this.presence = presence;
103 public MustDefinition getMust() {
107 public void setMust(MustDefinition must) {
111 public Integer getMinElements() {
115 public void setMinElements(Integer minElements) {
116 this.minElements = minElements;
119 public Integer getMaxElements() {
123 public void setMaxElements(Integer maxElements) {
124 this.maxElements = maxElements;
127 public String getName() {
131 public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
132 return addedUnknownNodes;
135 public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
136 addedUnknownNodes.add(unknownNode);
140 public Object build() {
145 public int hashCode() {
146 final int prime = 31;
148 result = prime * result + ((addedUnknownNodes == null) ? 0 : addedUnknownNodes.hashCode());
149 result = prime * result + ((config == null) ? 0 : config.hashCode());
150 result = prime * result + ((defaultStr == null) ? 0 : defaultStr.hashCode());
151 result = prime * result + ((description == null) ? 0 : description.hashCode());
152 result = prime * result + ((mandatory == null) ? 0 : mandatory.hashCode());
153 result = prime * result + ((maxElements == null) ? 0 : maxElements.hashCode());
154 result = prime * result + ((minElements == null) ? 0 : minElements.hashCode());
155 result = prime * result + ((must == null) ? 0 : must.hashCode());
156 result = prime * result + ((name == null) ? 0 : name.hashCode());
157 result = prime * result + ((parent == null) ? 0 : parent.hashCode());
158 result = prime * result + ((presence == null) ? 0 : presence.hashCode());
159 result = prime * result + ((reference == null) ? 0 : reference.hashCode());
164 public boolean equals(Object obj) {
169 if (getClass() != obj.getClass())
171 RefineHolder other = (RefineHolder) obj;
172 if (addedUnknownNodes == null) {
173 if (other.addedUnknownNodes != null)
175 } else if (!addedUnknownNodes.equals(other.addedUnknownNodes))
177 if (config == null) {
178 if (other.config != null)
180 } else if (!config.equals(other.config))
182 if (defaultStr == null) {
183 if (other.defaultStr != null)
185 } else if (!defaultStr.equals(other.defaultStr))
187 if (description == null) {
188 if (other.description != null)
190 } else if (!description.equals(other.description))
192 if (mandatory == null) {
193 if (other.mandatory != null)
195 } else if (!mandatory.equals(other.mandatory))
197 if (maxElements == null) {
198 if (other.maxElements != null)
200 } else if (!maxElements.equals(other.maxElements))
202 if (minElements == null) {
203 if (other.minElements != null)
205 } else if (!minElements.equals(other.minElements))
208 if (other.must != null)
210 } else if (!must.equals(other.must))
213 if (other.name != null)
215 } else if (!name.equals(other.name))
217 if (parent == null) {
218 if (other.parent != null)
220 } else if (!parent.equals(other.parent))
222 if (presence == null) {
223 if (other.presence != null)
225 } else if (!presence.equals(other.presence))
227 if (reference == null) {
228 if (other.reference != null)
230 } else if (!reference.equals(other.reference))
236 public String toString() {
237 return "revine " + name;