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.IntegerTypeDefinition;
15 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
18 * Implementation of Yang int8 built-in type. <br>
19 * int8 represents integer values between -128 and 127, inclusively. The Java
20 * counterpart of Yang int8 built-in type is {@link Byte}.
22 * @see AbstractSignedInteger
24 public final class Int8 extends AbstractSignedInteger {
26 private static final QName name = BaseTypes.constructQName("int8");
27 private Byte defaultValue = null;
28 private static final String description = "represents integer values between -128 and 127, inclusively.";
29 private final IntegerTypeDefinition baseType;
32 super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
36 public Int8(final SchemaPath path) {
37 super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
38 this.baseType = new Int8();
41 public Int8(final SchemaPath path, final Byte defaultValue) {
42 super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
43 this.baseType = new Int8();
44 this.defaultValue = defaultValue;
47 public Int8(final SchemaPath path,
48 final List<RangeConstraint> rangeStatements, final String units,
49 final Byte defaultValue) {
50 super(path, name, description, rangeStatements, units);
51 this.baseType = new Int8();
52 this.defaultValue = defaultValue;
59 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
62 public IntegerTypeDefinition getBaseType() {
70 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
74 public Object getDefaultValue() {
79 public int hashCode() {
81 int result = super.hashCode();
82 result = prime * result
83 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
88 public boolean equals(Object obj) {
92 if (!super.equals(obj)) {
95 if (getClass() != obj.getClass()) {
98 Int8 other = (Int8) obj;
99 if (defaultValue == null) {
100 if (other.defaultValue != null) {
103 } else if (!defaultValue.equals(other.defaultValue)) {
110 public String toString() {
111 StringBuilder builder = new StringBuilder();
112 builder.append("Int8 [defaultValue=");
113 builder.append(defaultValue);
114 builder.append(", AbstractInteger=");
115 builder.append(super.toString());
117 return builder.toString();