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 class BooleanType implements BooleanTypeDefinition {
26 private final QName name = BaseTypes.constructQName("boolean");
27 private final SchemaPath path = BaseTypes.schemaPath(name);
28 private final String description = "The boolean built-in type represents a boolean value.";
29 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
31 private final Boolean defaultValue;
32 private String units = "";
35 * Default constructor with default value set to "false".
37 public BooleanType() {
43 * Boolean Type constructor.
45 * @param defaultValue Default Value
47 public BooleanType(final Boolean defaultValue) {
49 this.defaultValue = defaultValue;
53 * Boolean Type constructor.
55 * @param defaultValue Default Value
58 public BooleanType(final Boolean defaultValue, final String units) {
60 this.defaultValue = defaultValue;
67 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
70 public BooleanTypeDefinition getBaseType() {
77 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
80 public String getUnits() {
87 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
90 public Object getDefaultValue() {
97 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
100 public QName getQName() {
107 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
110 public SchemaPath getPath() {
117 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
120 public String getDescription() {
127 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
130 public String getReference() {
137 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
140 public Status getStatus() {
141 return Status.CURRENT;
145 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
146 return Collections.emptyList();
150 public int hashCode() {
151 final int prime = 31;
153 result = prime * result
154 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
155 result = prime * result
156 + ((description == null) ? 0 : description.hashCode());
157 result = prime * result + ((name == null) ? 0 : name.hashCode());
158 result = prime * result + ((path == null) ? 0 : path.hashCode());
159 result = prime * result
160 + ((reference == null) ? 0 : reference.hashCode());
161 result = prime * result + ((units == null) ? 0 : units.hashCode());
166 public boolean equals(Object obj) {
173 if (getClass() != obj.getClass()) {
176 BooleanType other = (BooleanType) obj;
177 if (defaultValue == null) {
178 if (other.defaultValue != null) {
181 } else if (!defaultValue.equals(other.defaultValue)) {
184 if (description == null) {
185 if (other.description != null) {
188 } else if (!description.equals(other.description)) {
192 if (other.name != null) {
195 } else if (!name.equals(other.name)) {
199 if (other.path != null) {
202 } else if (!path.equals(other.path)) {
205 if (reference == null) {
206 if (other.reference != null) {
209 } else if (!reference.equals(other.reference)) {
213 if (other.units != null) {
216 } else if (!units.equals(other.units)) {
223 public String toString() {
224 StringBuilder builder = new StringBuilder();
225 builder.append("BooleanType [name=");
226 builder.append(name);
227 builder.append(", path=");
228 builder.append(path);
229 builder.append(", description=");
230 builder.append(description);
231 builder.append(", reference=");
232 builder.append(reference);
233 builder.append(", defaultValue=");
234 builder.append(defaultValue);
235 builder.append(", units=");
236 builder.append(units);
238 return builder.toString();