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.FeatureDefinition;
15 import org.opendaylight.controller.yang.model.api.SchemaPath;
16 import org.opendaylight.controller.yang.model.api.Status;
17 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
20 public class FeatureBuilder implements SchemaNodeBuilder {
22 private final FeatureDefinitionImpl instance;
23 private final QName qname;
25 FeatureBuilder(QName qname) {
27 instance = new FeatureDefinitionImpl(qname);
31 public FeatureDefinitionImpl build() {
36 public QName getQName() {
41 public void setPath(SchemaPath path) {
42 instance.setPath(path);
46 public void setDescription(String description) {
47 instance.setDescription(description);
51 public void setReference(String reference) {
52 instance.setReference(reference);
56 public void setStatus(Status status) {
57 instance.setStatus(status);
60 private static class FeatureDefinitionImpl implements FeatureDefinition {
61 private final QName qname;
62 private SchemaPath path;
63 private String description;
64 private String reference;
65 private Status status;
66 private List<UnknownSchemaNode> unknownSchemaNodes = Collections
69 private FeatureDefinitionImpl(QName qname) {
74 public QName getQName() {
79 public SchemaPath getPath() {
83 private void setPath(SchemaPath path) {
89 public String getDescription() {
93 private void setDescription(String description) {
94 this.description = description;
98 public String getReference() {
102 private void setReference(String reference) {
103 this.reference = reference;
107 public Status getStatus() {
111 private void setStatus(Status status) {
112 this.status = status;
116 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
117 return unknownSchemaNodes;
121 public int hashCode() {
122 final int prime = 31;
124 result = prime * result + ((qname == null) ? 0 : qname.hashCode());
125 result = prime * result + ((path == null) ? 0 : path.hashCode());
126 result = prime * result
127 + ((description == null) ? 0 : description.hashCode());
128 result = prime * result
129 + ((reference == null) ? 0 : reference.hashCode());
130 result = prime * result
131 + ((status == null) ? 0 : status.hashCode());
136 public boolean equals(Object obj) {
143 if (getClass() != obj.getClass()) {
146 FeatureDefinitionImpl other = (FeatureDefinitionImpl) obj;
148 if (other.qname != null) {
151 } else if (!qname.equals(other.qname)) {
155 if (other.path != null) {
158 } else if (!path.equals(other.path)) {
161 if (description == null) {
162 if (other.description != null) {
165 } else if (!description.equals(other.description)) {
168 if (reference == null) {
169 if (other.reference != null) {
172 } else if (!reference.equals(other.reference)) {
175 if (status == null) {
176 if (other.status != null) {
179 } else if (!status.equals(other.status)) {
186 public String toString() {
187 StringBuilder sb = new StringBuilder(
188 FeatureDefinitionImpl.class.getSimpleName());
189 sb.append("[name=" + qname);
190 sb.append(", path=" + path);
191 sb.append(", description=" + description);
192 sb.append(", reference=" + reference);
193 sb.append(", status=" + status + "]");
194 return sb.toString();