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.ExtensionDefinition;
\r
16 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
17 import org.opendaylight.controller.yang.model.api.Status;
\r
19 public class BooleanType implements BooleanTypeDefinition {
\r
21 private final QName name = BaseTypes.constructQName("boolean");
\r
22 private final SchemaPath path = BaseTypes.schemaPath(name);
\r
23 private final String description = "";
\r
24 private final String reference = "";
\r
26 private final Boolean defaultValue;
\r
27 private String units = "";
\r
30 * Default constructor with default value set to "false".
\r
32 public BooleanType() {
\r
34 defaultValue = false;
\r
40 * @param defaultValue
\r
42 public BooleanType(final Boolean defaultValue) {
\r
44 this.defaultValue = defaultValue;
\r
50 * @param defaultValue
\r
53 public BooleanType(final Boolean defaultValue, final String units) {
\r
55 this.defaultValue = defaultValue;
\r
62 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
65 public BooleanTypeDefinition getBaseType() {
\r
72 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
75 public String getUnits() {
\r
82 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
85 public Object getDefaultValue() {
\r
86 return defaultValue;
\r
92 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
95 public QName getQName() {
\r
102 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
105 public SchemaPath getPath() {
\r
112 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
115 public String getDescription() {
\r
116 return description;
\r
122 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
125 public String getReference() {
\r
132 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
135 public Status getStatus() {
\r
136 return Status.CURRENT;
\r
140 public List<ExtensionDefinition> getExtensionSchemaNodes() {
\r
141 return Collections.emptyList();
\r
145 public int hashCode() {
\r
146 final int prime = 31;
\r
148 result = prime * result
\r
149 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
\r
150 result = prime * result
\r
151 + ((description == null) ? 0 : description.hashCode());
\r
152 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
153 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
154 result = prime * result
\r
155 + ((reference == null) ? 0 : reference.hashCode());
\r
156 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
161 public boolean equals(Object obj) {
\r
168 if (getClass() != obj.getClass()) {
\r
171 BooleanType other = (BooleanType) obj;
\r
172 if (defaultValue == null) {
\r
173 if (other.defaultValue != null) {
\r
176 } else if (!defaultValue.equals(other.defaultValue)) {
\r
179 if (description == null) {
\r
180 if (other.description != null) {
\r
183 } else if (!description.equals(other.description)) {
\r
186 if (name == null) {
\r
187 if (other.name != null) {
\r
190 } else if (!name.equals(other.name)) {
\r
193 if (path == null) {
\r
194 if (other.path != null) {
\r
197 } else if (!path.equals(other.path)) {
\r
200 if (reference == null) {
\r
201 if (other.reference != null) {
\r
204 } else if (!reference.equals(other.reference)) {
\r
207 if (units == null) {
\r
208 if (other.units != null) {
\r
211 } else if (!units.equals(other.units)) {
\r
218 public String toString() {
\r
219 StringBuilder builder = new StringBuilder();
\r
220 builder.append("BooleanType [name=");
\r
221 builder.append(name);
\r
222 builder.append(", path=");
\r
223 builder.append(path);
\r
224 builder.append(", description=");
\r
225 builder.append(description);
\r
226 builder.append(", reference=");
\r
227 builder.append(reference);
\r
228 builder.append(", defaultValue=");
\r
229 builder.append(defaultValue);
\r
230 builder.append(", units=");
\r
231 builder.append(units);
\r
232 builder.append("]");
\r
233 return builder.toString();
\r