Added getParent() method to DataSchemaNode and DataNodeContainer. Fixed Bugs.
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / util / RefineHolder.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.util;
9
10 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
11 import org.opendaylight.yangtools.yang.model.api.YangNode;
12 import org.opendaylight.yangtools.yang.parser.builder.api.AbstractBuilder;
13
14 public final class RefineHolder extends AbstractBuilder {
15     private final String name;
16     private String defaultStr;
17     private String description;
18     private String reference;
19     private Boolean config;
20     private Boolean mandatory;
21     private Boolean presence;
22     private MustDefinition must;
23     private Integer minElements;
24     private Integer maxElements;
25
26     public RefineHolder(final String moduleName, final int line, final String name) {
27         super(moduleName, line);
28         this.name = name;
29     }
30
31     public String getDefaultStr() {
32         return defaultStr;
33     }
34
35     public void setDefaultStr(final String defaultStr) {
36         this.defaultStr = defaultStr;
37     }
38
39     public String getDescription() {
40         return description;
41     }
42
43     public void setDescription(final String description) {
44         this.description = description;
45     }
46
47     public String getReference() {
48         return reference;
49     }
50
51     public void setReference(final String reference) {
52         this.reference = reference;
53     }
54
55     public Boolean isConfiguration() {
56         return config;
57     }
58
59     public void setConfiguration(final Boolean config) {
60         this.config = config;
61     }
62
63     public Boolean isMandatory() {
64         return mandatory;
65     }
66
67     public void setMandatory(Boolean mandatory) {
68         this.mandatory = mandatory;
69     }
70
71     public Boolean isPresence() {
72         return presence;
73     }
74
75     public void setPresence(Boolean presence) {
76         this.presence = presence;
77     }
78
79     public MustDefinition getMust() {
80         return must;
81     }
82
83     public void setMust(MustDefinition must) {
84         this.must = must;
85     }
86
87     public Integer getMinElements() {
88         return minElements;
89     }
90
91     public void setMinElements(Integer minElements) {
92         this.minElements = minElements;
93     }
94
95     public Integer getMaxElements() {
96         return maxElements;
97     }
98
99     public void setMaxElements(Integer maxElements) {
100         this.maxElements = maxElements;
101     }
102
103     public String getName() {
104         return name;
105     }
106
107     @Override
108     public Object build(YangNode parent) {
109         return null;
110     }
111
112     @Override
113     public int hashCode() {
114         final int prime = 31;
115         int result = 1;
116         result = prime * result + ((addedUnknownNodes == null) ? 0 : addedUnknownNodes.hashCode());
117         result = prime * result + ((config == null) ? 0 : config.hashCode());
118         result = prime * result + ((defaultStr == null) ? 0 : defaultStr.hashCode());
119         result = prime * result + ((description == null) ? 0 : description.hashCode());
120         result = prime * result + ((mandatory == null) ? 0 : mandatory.hashCode());
121         result = prime * result + ((maxElements == null) ? 0 : maxElements.hashCode());
122         result = prime * result + ((minElements == null) ? 0 : minElements.hashCode());
123         result = prime * result + ((must == null) ? 0 : must.hashCode());
124         result = prime * result + ((name == null) ? 0 : name.hashCode());
125         result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
126         result = prime * result + ((presence == null) ? 0 : presence.hashCode());
127         result = prime * result + ((reference == null) ? 0 : reference.hashCode());
128         return result;
129     }
130
131     @Override
132     public boolean equals(Object obj) {
133         if (this == obj) {
134             return true;
135         }
136         if (obj == null) {
137             return false;
138         }
139         if (getClass() != obj.getClass()) {
140             return false;
141         }
142         RefineHolder other = (RefineHolder) obj;
143         if (addedUnknownNodes == null) {
144             if (other.addedUnknownNodes != null) {
145                 return false;
146             }
147         } else if (!addedUnknownNodes.equals(other.addedUnknownNodes)) {
148             return false;
149         }
150         if (config == null) {
151             if (other.config != null) {
152                 return false;
153             }
154         } else if (!config.equals(other.config)) {
155             return false;
156         }
157         if (defaultStr == null) {
158             if (other.defaultStr != null) {
159                 return false;
160             }
161         } else if (!defaultStr.equals(other.defaultStr)) {
162             return false;
163         }
164         if (description == null) {
165             if (other.description != null) {
166                 return false;
167             }
168         } else if (!description.equals(other.description)) {
169             return false;
170         }
171         if (mandatory == null) {
172             if (other.mandatory != null) {
173                 return false;
174             }
175         } else if (!mandatory.equals(other.mandatory)) {
176             return false;
177         }
178         if (maxElements == null) {
179             if (other.maxElements != null) {
180                 return false;
181             }
182         } else if (!maxElements.equals(other.maxElements)) {
183             return false;
184         }
185         if (minElements == null) {
186             if (other.minElements != null) {
187                 return false;
188             }
189         } else if (!minElements.equals(other.minElements)) {
190             return false;
191         }
192         if (must == null) {
193             if (other.must != null) {
194                 return false;
195             }
196         } else if (!must.equals(other.must)) {
197             return false;
198         }
199         if (name == null) {
200             if (other.name != null) {
201                 return false;
202             }
203         } else if (!name.equals(other.name)) {
204             return false;
205         }
206         if (parentBuilder == null) {
207             if (other.parentBuilder != null) {
208                 return false;
209             }
210         } else if (!parentBuilder.equals(other.parentBuilder)) {
211             return false;
212         }
213         if (presence == null) {
214             if (other.presence != null) {
215                 return false;
216             }
217         } else if (!presence.equals(other.presence)) {
218             return false;
219         }
220         if (reference == null) {
221             if (other.reference != null) {
222                 return false;
223             }
224         } else if (!reference.equals(other.reference)) {
225             return false;
226         }
227         return true;
228     }
229
230     @Override
231     public String toString() {
232         return "refine " + name;
233     }
234
235 }