When a node is going down, remove edges in both directions associated with the node.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / 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.controller.yang.parser.util;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
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;
16
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>();
31
32     public RefineHolder(final int line, final String name) {
33         this.name = name;
34         this.line = line;
35     }
36
37     @Override
38     public int getLine() {
39         return line;
40     }
41
42     @Override
43     public Builder getParent() {
44         return parent;
45     }
46
47     @Override
48     public void setParent(final Builder parent) {
49         this.parent = parent;
50     }
51
52     public String getDefaultStr() {
53         return defaultStr;
54     }
55
56     public void setDefaultStr(final String defaultStr) {
57         this.defaultStr = defaultStr;
58     }
59
60     public String getDescription() {
61         return description;
62     }
63
64     public void setDescription(final String description) {
65         this.description = description;
66     }
67
68     public String getReference() {
69         return reference;
70     }
71
72     public void setReference(final String reference) {
73         this.reference = reference;
74     }
75
76     public Boolean isConfiguration() {
77         return config;
78     }
79
80     public void setConfiguration(final Boolean config) {
81         this.config = config;
82     }
83
84     public Boolean isMandatory() {
85         return mandatory;
86     }
87
88     public void setMandatory(Boolean mandatory) {
89         this.mandatory = mandatory;
90     }
91
92     public Boolean isPresence() {
93         return presence;
94     }
95
96     public void setPresence(Boolean presence) {
97         this.presence = presence;
98     }
99
100     public MustDefinition getMust() {
101         return must;
102     }
103
104     public void setMust(MustDefinition must) {
105         this.must = must;
106     }
107
108     public Integer getMinElements() {
109         return minElements;
110     }
111
112     public void setMinElements(Integer minElements) {
113         this.minElements = minElements;
114     }
115
116     public Integer getMaxElements() {
117         return maxElements;
118     }
119
120     public void setMaxElements(Integer maxElements) {
121         this.maxElements = maxElements;
122     }
123
124     public String getName() {
125         return name;
126     }
127
128     @Override
129     public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
130         return addedUnknownNodes;
131     }
132
133     @Override
134     public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
135         addedUnknownNodes.add(unknownNode);
136     }
137
138     @Override
139     public Object build() {
140         return null;
141     }
142
143     @Override
144     public int hashCode() {
145         final int prime = 31;
146         int result = 1;
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());
159         return result;
160     }
161
162     @Override
163     public boolean equals(Object obj) {
164         if (this == obj)
165             return true;
166         if (obj == null)
167             return false;
168         if (getClass() != obj.getClass())
169             return false;
170         RefineHolder other = (RefineHolder) obj;
171         if (addedUnknownNodes == null) {
172             if (other.addedUnknownNodes != null)
173                 return false;
174         } else if (!addedUnknownNodes.equals(other.addedUnknownNodes))
175             return false;
176         if (config == null) {
177             if (other.config != null)
178                 return false;
179         } else if (!config.equals(other.config))
180             return false;
181         if (defaultStr == null) {
182             if (other.defaultStr != null)
183                 return false;
184         } else if (!defaultStr.equals(other.defaultStr))
185             return false;
186         if (description == null) {
187             if (other.description != null)
188                 return false;
189         } else if (!description.equals(other.description))
190             return false;
191         if (mandatory == null) {
192             if (other.mandatory != null)
193                 return false;
194         } else if (!mandatory.equals(other.mandatory))
195             return false;
196         if (maxElements == null) {
197             if (other.maxElements != null)
198                 return false;
199         } else if (!maxElements.equals(other.maxElements))
200             return false;
201         if (minElements == null) {
202             if (other.minElements != null)
203                 return false;
204         } else if (!minElements.equals(other.minElements))
205             return false;
206         if (must == null) {
207             if (other.must != null)
208                 return false;
209         } else if (!must.equals(other.must))
210             return false;
211         if (name == null) {
212             if (other.name != null)
213                 return false;
214         } else if (!name.equals(other.name))
215             return false;
216         if (parent == null) {
217             if (other.parent != null)
218                 return false;
219         } else if (!parent.equals(other.parent))
220             return false;
221         if (presence == null) {
222             if (other.presence != null)
223                 return false;
224         } else if (!presence.equals(other.presence))
225             return false;
226         if (reference == null) {
227             if (other.reference != null)
228                 return false;
229         } else if (!reference.equals(other.reference))
230             return false;
231         return true;
232     }
233
234     @Override
235     public String toString() {
236         return "revine " + name;
237     }
238
239 }