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.List;
12 import org.opendaylight.controller.yang.common.QName;
13 import org.opendaylight.controller.yang.model.api.SchemaPath;
14 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
15 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
18 * Implementation of Yang uint8 built-in type.
20 * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
21 * Yang uint8 built-in type is {@link Short}.
23 * @see AbstractUnsignedInteger
25 public final class Uint8 extends AbstractUnsignedInteger {
27 private static final QName name = BaseTypes.constructQName("uint8");
28 private Short defaultValue = null;
29 private static final String description =
30 "uint8 represents integer values between 0 and 255, inclusively.";
31 private final UnsignedIntegerTypeDefinition baseType;
34 super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
38 public Uint8(final SchemaPath path) {
39 super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
40 this.baseType = new Uint8();
43 public Uint8(final SchemaPath path, final Short defaultValue) {
44 super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
45 this.baseType = new Uint8();
46 this.defaultValue = defaultValue;
49 public Uint8(final SchemaPath path, final List<RangeConstraint> rangeStatements,
50 final String units, final Short defaultValue) {
51 super(path, name, description, rangeStatements, units);
52 this.baseType = new Uint8();
53 this.defaultValue = defaultValue;
59 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
62 public UnsignedIntegerTypeDefinition getBaseType() {
69 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
72 public Object getDefaultValue() {
77 public int hashCode() {
79 int result = super.hashCode();
80 result = prime * result
81 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
86 public boolean equals(Object obj) {
90 if (!super.equals(obj)) {
93 if (getClass() != obj.getClass()) {
96 Uint8 other = (Uint8) obj;
97 if (defaultValue == null) {
98 if (other.defaultValue != null) {
101 } else if (!defaultValue.equals(other.defaultValue)) {
108 public String toString() {
109 StringBuilder builder = new StringBuilder();
110 builder.append("Uint8 [defaultValue=");
111 builder.append(defaultValue);
112 builder.append(", AbstractInteger=");
113 builder.append(super.toString());
115 return builder.toString();