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.util;
\r
10 import java.util.Collections;
\r
11 import java.util.List;
\r
13 import org.opendaylight.controller.model.api.type.EnumTypeDefinition;
\r
14 import org.opendaylight.controller.yang.common.QName;
\r
15 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
16 import org.opendaylight.controller.yang.model.api.Status;
\r
17 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
\r
19 public class EnumerationType implements EnumTypeDefinition {
\r
21 private final QName name = BaseTypes.constructQName("enumeration");
\r
22 private final SchemaPath path = BaseTypes.schemaPath(name);
\r
23 private final String description = "The enumeration built-in type represents values from a set of assigned names.";
\r
24 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.6";
\r
26 private final List<EnumPair> defaultEnum;
\r
27 private final List<EnumPair> enums;
\r
28 private String units = "";
\r
30 public EnumerationType(final List<EnumPair> enums) {
\r
34 defaultEnum = Collections.emptyList();
\r
37 public EnumerationType(final List<EnumPair> defaultEnum,
\r
38 final List<EnumPair> enums, final String units) {
\r
40 this.defaultEnum = defaultEnum;
\r
48 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
51 public EnumTypeDefinition getBaseType() {
\r
58 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
61 public String getUnits() {
\r
68 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
71 public Object getDefaultValue() {
\r
78 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
81 public QName getQName() {
\r
88 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
91 public SchemaPath getPath() {
\r
98 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
101 public String getDescription() {
\r
102 return description;
\r
108 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
111 public String getReference() {
\r
118 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
121 public Status getStatus() {
\r
122 return Status.CURRENT;
\r
128 * @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()
\r
131 public List<EnumPair> getValues() {
\r
136 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
137 return Collections.emptyList();
\r
141 public int hashCode() {
\r
142 final int prime = 31;
\r
144 result = prime * result
\r
145 + ((defaultEnum == null) ? 0 : defaultEnum.hashCode());
\r
146 result = prime * result
\r
147 + ((description == null) ? 0 : description.hashCode());
\r
148 result = prime * result + ((enums == null) ? 0 : enums.hashCode());
\r
149 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
150 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
151 result = prime * result
\r
152 + ((reference == null) ? 0 : reference.hashCode());
\r
153 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
158 public boolean equals(Object obj) {
\r
165 if (getClass() != obj.getClass()) {
\r
168 EnumerationType other = (EnumerationType) obj;
\r
169 if (defaultEnum == null) {
\r
170 if (other.defaultEnum != null) {
\r
173 } else if (!defaultEnum.equals(other.defaultEnum)) {
\r
176 if (description == null) {
\r
177 if (other.description != null) {
\r
180 } else if (!description.equals(other.description)) {
\r
183 if (enums == null) {
\r
184 if (other.enums != null) {
\r
187 } else if (!enums.equals(other.enums)) {
\r
190 if (name == null) {
\r
191 if (other.name != null) {
\r
194 } else if (!name.equals(other.name)) {
\r
197 if (path == null) {
\r
198 if (other.path != null) {
\r
201 } else if (!path.equals(other.path)) {
\r
204 if (reference == null) {
\r
205 if (other.reference != null) {
\r
208 } else if (!reference.equals(other.reference)) {
\r
211 if (units == null) {
\r
212 if (other.units != null) {
\r
215 } else if (!units.equals(other.units)) {
\r
222 public String toString() {
\r
223 StringBuilder builder = new StringBuilder();
\r
224 builder.append("EnumerationType [name=");
\r
225 builder.append(name);
\r
226 builder.append(", path=");
\r
227 builder.append(path);
\r
228 builder.append(", description=");
\r
229 builder.append(description);
\r
230 builder.append(", reference=");
\r
231 builder.append(reference);
\r
232 builder.append(", defaultEnum=");
\r
233 builder.append(defaultEnum);
\r
234 builder.append(", enums=");
\r
235 builder.append(enums);
\r
236 builder.append(", units=");
\r
237 builder.append(units);
\r
238 builder.append("]");
\r
239 return builder.toString();
\r