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.List;
\r
12 import org.opendaylight.controller.model.api.type.RangeConstraint;
\r
13 import org.opendaylight.controller.model.api.type.UnsignedIntegerTypeDefinition;
\r
14 import org.opendaylight.controller.yang.common.QName;
\r
17 * Implementation of Yang uint8 built-in type.
\r
19 * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
\r
20 * Yang uint8 built-in type is {@link Short}.
\r
22 * @see AbstractUnsignedInteger
\r
24 public class Uint8 extends AbstractUnsignedInteger {
\r
26 private static final QName name = BaseTypes.constructQName("uint8");
\r
27 private Short defaultValue = null;
\r
28 private static final String description =
\r
29 "uint8 represents integer values between 0 and 255, inclusively.";
\r
32 super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
\r
35 public Uint8(final Short defaultValue) {
\r
36 super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
\r
37 this.defaultValue = defaultValue;
\r
40 public Uint8(final List<RangeConstraint> rangeStatements,
\r
41 final String units, final Short defaultValue) {
\r
42 super(name, description, rangeStatements, units);
\r
43 this.defaultValue = defaultValue;
\r
49 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
52 public UnsignedIntegerTypeDefinition getBaseType() {
\r
59 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
62 public Object getDefaultValue() {
\r
63 return defaultValue;
\r
67 public int hashCode() {
\r
68 final int prime = 31;
\r
69 int result = super.hashCode();
\r
70 result = prime * result
\r
71 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
\r
76 public boolean equals(Object obj) {
\r
80 if (!super.equals(obj)) {
\r
83 if (getClass() != obj.getClass()) {
\r
86 Uint8 other = (Uint8) obj;
\r
87 if (defaultValue == null) {
\r
88 if (other.defaultValue != null) {
\r
91 } else if (!defaultValue.equals(other.defaultValue)) {
\r
98 public String toString() {
\r
99 StringBuilder builder = new StringBuilder();
\r
100 builder.append("Uint8 [defaultValue=");
\r
101 builder.append(defaultValue);
\r
102 builder.append(", AbstractInteger=");
\r
103 builder.append(super.toString());
\r
104 builder.append("]");
\r
105 return builder.toString();
\r