2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.controller.model.parser.builder;
\r
10 import java.util.List;
\r
12 import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;
\r
13 import org.opendaylight.controller.yang.common.QName;
\r
14 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
\r
15 import org.opendaylight.controller.yang.model.api.FeatureDefinition;
\r
16 import org.opendaylight.controller.yang.model.api.SchemaNode;
\r
17 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
18 import org.opendaylight.controller.yang.model.api.Status;
\r
21 public class FeatureBuilder implements SchemaNodeBuilder {
\r
23 private final FeatureDefinitionImpl instance;
\r
24 private final QName qname;
\r
26 FeatureBuilder(QName qname) {
\r
28 instance = new FeatureDefinitionImpl(qname);
\r
32 public SchemaNode build() {
\r
37 public QName getQName() {
\r
42 public void setPath(SchemaPath path) {
\r
43 instance.setPath(path);
\r
47 public void setDescription(String description) {
\r
48 instance.setDescription(description);
\r
52 public void setReference(String reference) {
\r
53 instance.setReference(reference);
\r
57 public void setStatus(Status status) {
\r
58 instance.setStatus(status);
\r
61 private static class FeatureDefinitionImpl implements FeatureDefinition {
\r
63 private final QName qname;
\r
64 private SchemaPath path;
\r
65 private String description;
\r
66 private String reference;
\r
67 private Status status;
\r
69 private FeatureDefinitionImpl(QName qname) {
\r
74 public QName getQName() {
\r
79 public SchemaPath getPath() {
\r
82 private void setPath(SchemaPath path) {
\r
87 public String getDescription() {
\r
90 private void setDescription(String description) {
\r
91 this.description = description;
\r
95 public String getReference() {
\r
98 private void setReference(String reference) {
\r
99 this.reference = reference;
\r
103 public Status getStatus() {
\r
106 private void setStatus(Status status) {
\r
107 this.status = status;
\r
111 public List<ExtensionDefinition> getExtensionSchemaNodes() {
\r
112 // TODO Auto-generated method stub
\r
117 public int hashCode() {
\r
118 final int prime = 31;
\r
120 result = prime * result + ((qname == null) ? 0 : qname.hashCode());
\r
121 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
122 result = prime * result + ((description == null) ? 0 : description.hashCode());
\r
123 result = prime * result + ((reference == null) ? 0 : reference.hashCode());
\r
124 result = prime * result + ((status == null) ? 0 : status.hashCode());
\r
129 public boolean equals(Object obj) {
\r
136 if (getClass() != obj.getClass()) {
\r
139 FeatureDefinitionImpl other = (FeatureDefinitionImpl) obj;
\r
140 if (qname == null) {
\r
141 if (other.qname != null) {
\r
144 } else if (!qname.equals(other.qname)) {
\r
147 if (path == null) {
\r
148 if (other.path != null) {
\r
151 } else if (!path.equals(other.path)) {
\r
154 if (description == null) {
\r
155 if (other.description != null) {
\r
158 } else if (!description.equals(other.description)) {
\r
161 if (reference == null) {
\r
162 if (other.reference != null) {
\r
165 } else if (!reference.equals(other.reference)) {
\r
168 if (status == null) {
\r
169 if (other.status != null) {
\r
172 } else if (!status.equals(other.status)) {
\r
179 public String toString() {
\r
180 StringBuilder sb = new StringBuilder(FeatureDefinitionImpl.class.getSimpleName());
\r
181 sb.append("[name="+ qname);
\r
182 sb.append(", path="+ path);
\r
183 sb.append(", description="+ description);
\r
184 sb.append(", reference="+ reference);
\r
185 sb.append(", status="+ status +"]");
\r
186 return sb.toString();
\r