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;
11 import java.util.Collections;
12 import java.util.Date;
13 import java.util.List;
15 import org.opendaylight.controller.yang.common.QName;
16 import org.opendaylight.controller.yang.model.api.SchemaPath;
17 import org.opendaylight.controller.yang.model.api.Status;
18 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
19 import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
22 * The <code>default</code> implementation of Boolean Type Definition interface.
24 * @see BooleanTypeDefinition
26 public class BooleanType implements BooleanTypeDefinition {
28 private final QName name = BaseTypes.constructQName("boolean");
29 private final SchemaPath path;
30 private final String description = "The boolean built-in type represents a boolean value.";
31 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
32 private final BooleanTypeDefinition baseType;
33 private final Boolean defaultValue;
34 private String units = "";
37 * Default constructor with default value set to "false".
39 private BooleanType() {
41 this.defaultValue = false;
42 this.path = BaseTypes.schemaPath(name);
46 public BooleanType(final List<String> actualPath, final URI namespace,
47 final Date revision) {
49 this.defaultValue = false;
50 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
51 this.baseType = new BooleanType();
55 * Boolean Type constructor.
60 public BooleanType(final List<String> actualPath, final URI namespace,
61 final Date revision, final Boolean defaultValue) {
63 this.defaultValue = defaultValue;
64 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
65 this.baseType = new BooleanType();
69 * Boolean Type constructor.
76 public BooleanType(final List<String> actualPath, final URI namespace,
77 final Date revision, final Boolean defaultValue, final String units) {
79 this.defaultValue = defaultValue;
81 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
82 this.baseType = new BooleanType();
89 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
92 public BooleanTypeDefinition getBaseType() {
99 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
102 public String getUnits() {
110 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
114 public Object getDefaultValue() {
121 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
124 public QName getQName() {
131 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
134 public SchemaPath getPath() {
142 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
145 public String getDescription() {
152 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
155 public String getReference() {
162 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
165 public Status getStatus() {
166 return Status.CURRENT;
170 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
171 return Collections.emptyList();
175 public int hashCode() {
176 final int prime = 31;
178 result = prime * result
179 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
180 result = prime * result
181 + ((description == null) ? 0 : description.hashCode());
182 result = prime * result + ((name == null) ? 0 : name.hashCode());
183 result = prime * result + ((path == null) ? 0 : path.hashCode());
184 result = prime * result
185 + ((reference == null) ? 0 : reference.hashCode());
186 result = prime * result + ((units == null) ? 0 : units.hashCode());
191 public boolean equals(Object obj) {
198 if (getClass() != obj.getClass()) {
201 BooleanType other = (BooleanType) obj;
202 if (defaultValue == null) {
203 if (other.defaultValue != null) {
206 } else if (!defaultValue.equals(other.defaultValue)) {
209 if (description == null) {
210 if (other.description != null) {
213 } else if (!description.equals(other.description)) {
217 if (other.name != null) {
220 } else if (!name.equals(other.name)) {
224 if (other.path != null) {
227 } else if (!path.equals(other.path)) {
230 if (reference == null) {
231 if (other.reference != null) {
234 } else if (!reference.equals(other.reference)) {
238 if (other.units != null) {
241 } else if (!units.equals(other.units)) {
248 public String toString() {
249 StringBuilder builder = new StringBuilder();
250 builder.append("BooleanType [name=");
251 builder.append(name);
252 builder.append(", path=");
253 builder.append(path);
254 builder.append(", description=");
255 builder.append(description);
256 builder.append(", reference=");
257 builder.append(reference);
258 builder.append(", defaultValue=");
259 builder.append(defaultValue);
260 builder.append(", units=");
261 builder.append(units);
263 return builder.toString();