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