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