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 {
26 private final QName name = BaseTypes.constructQName("boolean");
27 private final SchemaPath path;
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";
30 private final BooleanTypeDefinition baseType;
31 private final Boolean defaultValue;
32 private String units = "";
35 * Default constructor with default value set to "false".
37 private BooleanType() {
39 this.defaultValue = false;
40 this.path = BaseTypes.schemaPath(name);
44 public BooleanType(final SchemaPath path) {
46 this.defaultValue = false;
48 this.baseType = new BooleanType();
52 * Boolean Type constructor.
57 public BooleanType(final SchemaPath path, final Boolean defaultValue) {
59 this.defaultValue = defaultValue;
61 this.baseType = new BooleanType();
65 * Boolean Type constructor.
72 public BooleanType(final SchemaPath path, final Boolean defaultValue, final String units) {
74 this.defaultValue = defaultValue;
77 this.baseType = new BooleanType();
84 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
87 public BooleanTypeDefinition getBaseType() {
94 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
97 public String getUnits() {
105 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
109 public Object getDefaultValue() {
116 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
119 public QName getQName() {
126 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
129 public SchemaPath getPath() {
137 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
140 public String getDescription() {
147 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
150 public String getReference() {
157 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
160 public Status getStatus() {
161 return Status.CURRENT;
165 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
166 return Collections.emptyList();
170 public int hashCode() {
171 final int prime = 31;
173 result = prime * result
174 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
175 result = prime * result
176 + ((description == null) ? 0 : description.hashCode());
177 result = prime * result + ((name == null) ? 0 : name.hashCode());
178 result = prime * result + ((path == null) ? 0 : path.hashCode());
179 result = prime * result
180 + ((reference == null) ? 0 : reference.hashCode());
181 result = prime * result + ((units == null) ? 0 : units.hashCode());
186 public boolean equals(Object obj) {
193 if (getClass() != obj.getClass()) {
196 BooleanType other = (BooleanType) obj;
197 if (defaultValue == null) {
198 if (other.defaultValue != null) {
201 } else if (!defaultValue.equals(other.defaultValue)) {
204 if (description == null) {
205 if (other.description != null) {
208 } else if (!description.equals(other.description)) {
212 if (other.name != null) {
215 } else if (!name.equals(other.name)) {
219 if (other.path != null) {
222 } else if (!path.equals(other.path)) {
225 if (reference == null) {
226 if (other.reference != null) {
229 } else if (!reference.equals(other.reference)) {
233 if (other.units != null) {
236 } else if (!units.equals(other.units)) {
243 public String toString() {
244 StringBuilder builder = new StringBuilder();
245 builder.append("BooleanType [name=");
246 builder.append(name);
247 builder.append(", path=");
248 builder.append(path);
249 builder.append(", description=");
250 builder.append(description);
251 builder.append(", reference=");
252 builder.append(reference);
253 builder.append(", defaultValue=");
254 builder.append(defaultValue);
255 builder.append(", units=");
256 builder.append(units);
258 return builder.toString();