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.util;
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.SchemaPath;
15 import org.opendaylight.controller.yang.model.api.Status;
16 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
20 * The <code>default</code> implementation of Boolean Type Definition interface.
22 * @see BooleanTypeDefinition
24 public final class BooleanType implements BooleanTypeDefinition {
25 private final QName name = BaseTypes.constructQName("boolean");
26 private final SchemaPath path;
27 private final String description = "The boolean built-in type represents a boolean value.";
28 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
29 private final BooleanTypeDefinition baseType;
30 private final Boolean defaultValue;
31 private final String units = "";
34 * Default constructor with default value set to "false".
36 public BooleanType(final SchemaPath path) {
38 this.defaultValue = false;
44 * Boolean Type constructor.
49 public BooleanType(final SchemaPath path, final Boolean defaultValue) {
51 this.defaultValue = defaultValue;
60 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
63 public BooleanTypeDefinition getBaseType() {
70 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
73 public String getUnits() {
81 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
85 public Object getDefaultValue() {
92 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
95 public QName getQName() {
102 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
105 public SchemaPath getPath() {
113 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
116 public String getDescription() {
123 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
126 public String getReference() {
133 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
136 public Status getStatus() {
137 return Status.CURRENT;
141 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
142 return Collections.emptyList();
146 public int hashCode() {
147 final int prime = 31;
149 result = prime * result
150 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
151 result = prime * result
152 + ((description == null) ? 0 : description.hashCode());
153 result = prime * result + ((name == null) ? 0 : name.hashCode());
154 result = prime * result + ((path == null) ? 0 : path.hashCode());
155 result = prime * result
156 + ((reference == null) ? 0 : reference.hashCode());
157 result = prime * result + ((units == null) ? 0 : units.hashCode());
162 public boolean equals(Object obj) {
169 if (getClass() != obj.getClass()) {
172 BooleanType other = (BooleanType) obj;
173 if (defaultValue == null) {
174 if (other.defaultValue != null) {
177 } else if (!defaultValue.equals(other.defaultValue)) {
180 if (description == null) {
181 if (other.description != null) {
184 } else if (!description.equals(other.description)) {
188 if (other.name != null) {
191 } else if (!name.equals(other.name)) {
195 if (other.path != null) {
198 } else if (!path.equals(other.path)) {
201 if (reference == null) {
202 if (other.reference != null) {
205 } else if (!reference.equals(other.reference)) {
209 if (other.units != null) {
212 } else if (!units.equals(other.units)) {
219 public String toString() {
220 StringBuilder builder = new StringBuilder();
221 builder.append("BooleanType [name=");
222 builder.append(name);
223 builder.append(", path=");
224 builder.append(path);
225 builder.append(", description=");
226 builder.append(description);
227 builder.append(", reference=");
228 builder.append(reference);
229 builder.append(", defaultValue=");
230 builder.append(defaultValue);
231 builder.append(", units=");
232 builder.append(units);
234 return builder.toString();