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.model.parser.builder.impl;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
15 import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
16 import org.opendaylight.controller.yang.model.api.SchemaPath;
17 import org.opendaylight.controller.yang.model.api.Status;
18 import org.opendaylight.controller.yang.model.api.TypeDefinition;
19 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
20 import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
21 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
22 import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
24 public class LeafListSchemaNodeBuilder implements SchemaNodeBuilder,
25 TypeAwareBuilder, DataSchemaNodeBuilder {
27 private final LeafListSchemaNodeImpl instance;
28 private final QName qname;
29 private final ConstraintsBuilder constraintsBuilder;
30 private TypeDefinition<?> type;
32 LeafListSchemaNodeBuilder(QName qname) {
34 instance = new LeafListSchemaNodeImpl(qname);
35 constraintsBuilder = new ConstraintsBuilder();
39 public LeafListSchemaNode build() {
40 instance.setConstraints(constraintsBuilder.build());
45 public QName getQName() {
50 public void setPath(SchemaPath path) {
51 instance.setPath(path);
55 public void setDescription(String description) {
56 instance.setDescription(description);
60 public void setReference(String reference) {
61 instance.setReference(reference);
65 public void setStatus(Status status) {
67 instance.setStatus(status);
72 public TypeDefinition<?> getType() {
77 public void setType(TypeDefinition<?> type) {
79 instance.setType(type);
83 public void setAugmenting(boolean augmenting) {
84 instance.setAugmenting(augmenting);
88 public void setConfiguration(boolean configuration) {
89 instance.setConfiguration(configuration);
93 public ConstraintsBuilder getConstraintsBuilder() {
94 return constraintsBuilder;
97 public void setUserOrdered(boolean userOrdered) {
98 instance.setUserOrdered(userOrdered);
101 private class LeafListSchemaNodeImpl implements LeafListSchemaNode {
102 private final QName qname;
103 private SchemaPath path;
104 private String description;
105 private String reference;
106 private Status status = Status.CURRENT;
107 private boolean augmenting;
108 private boolean configuration;
109 private ConstraintDefinition constraints;
110 private TypeDefinition<?> type;
111 private boolean userOrdered;
112 private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
114 private LeafListSchemaNodeImpl(QName qname) {
119 public QName getQName() {
124 public SchemaPath getPath() {
128 private void setPath(SchemaPath path) {
133 public String getDescription() {
137 private void setDescription(String description) {
138 this.description = description;
142 public String getReference() {
146 private void setReference(String reference) {
147 this.reference = reference;
151 public Status getStatus() {
155 private void setStatus(Status status) {
156 this.status = status;
160 public boolean isAugmenting() {
164 private void setAugmenting(boolean augmenting) {
165 this.augmenting = augmenting;
169 public boolean isConfiguration() {
170 return configuration;
173 private void setConfiguration(boolean configuration) {
174 this.configuration = configuration;
178 public ConstraintDefinition getConstraints() {
182 private void setConstraints(ConstraintDefinition constraints) {
183 this.constraints = constraints;
187 public TypeDefinition<?> getType() {
191 public void setType(TypeDefinition<? extends TypeDefinition<?>> type) {
196 public boolean isUserOrdered() {
200 private void setUserOrdered(boolean userOrdered) {
201 this.userOrdered = userOrdered;
205 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
206 return unknownSchemaNodes;
210 public int hashCode() {
211 final int prime = 31;
213 result = prime * result + ((qname == null) ? 0 : qname.hashCode());
214 result = prime * result + ((path == null) ? 0 : path.hashCode());
215 result = prime * result
216 + ((description == null) ? 0 : description.hashCode());
217 result = prime * result
218 + ((reference == null) ? 0 : reference.hashCode());
219 result = prime * result
220 + ((status == null) ? 0 : status.hashCode());
221 result = prime * result + (augmenting ? 1231 : 1237);
222 result = prime * result + (configuration ? 1231 : 1237);
223 result = prime * result
224 + ((constraints == null) ? 0 : constraints.hashCode());
225 result = prime * result + ((type == null) ? 0 : type.hashCode());
226 result = prime * result + (userOrdered ? 1231 : 1237);
231 public boolean equals(Object obj) {
238 if (getClass() != obj.getClass()) {
241 LeafListSchemaNodeImpl other = (LeafListSchemaNodeImpl) obj;
243 if (other.qname != null) {
246 } else if (!qname.equals(other.qname)) {
250 if (other.path != null) {
253 } else if (!path.equals(other.path)) {
256 if (description == null) {
257 if (other.description != null) {
260 } else if (!description.equals(other.description)) {
263 if (reference == null) {
264 if (other.reference != null) {
267 } else if (!reference.equals(other.reference)) {
270 if (status == null) {
271 if (other.status != null) {
274 } else if (!status.equals(other.status)) {
277 if (augmenting != other.augmenting) {
280 if (configuration != other.configuration) {
283 if (constraints == null) {
284 if (other.constraints != null) {
287 } else if (!constraints.equals(other.constraints)) {
291 if (other.type != null) {
294 } else if (!type.equals(other.type)) {
297 if (userOrdered != other.userOrdered) {
304 public String toString() {
305 StringBuilder sb = new StringBuilder(
306 LeafListSchemaNodeImpl.class.getSimpleName());
308 sb.append("qname=" + qname);
309 sb.append(", path=" + path);
310 sb.append(", description=" + description);
311 sb.append(", reference=" + reference);
312 sb.append(", status=" + status);
313 sb.append(", augmenting=" + augmenting);
314 sb.append(", configuration=" + configuration);
315 sb.append(", constraints=" + constraints);
316 sb.append(", type=" + type);
317 sb.append(", userOrdered=" + userOrdered);
319 return sb.toString();