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;
11 import java.util.Date;
12 import java.util.List;
14 import org.opendaylight.controller.yang.common.QName;
15 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
16 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
19 * Implementation of Yang int8 built-in type.
21 * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of
22 * Yang int8 built-in type is {@link Byte}.
24 * @see AbstractSignedInteger
26 public class Int8 extends AbstractSignedInteger {
28 private static final QName name = BaseTypes.constructQName("int8");
29 private Byte defaultValue = null;
30 private static final String description =
31 "represents integer values between -128 and 127, inclusively.";
32 private final IntegerTypeDefinition baseType;
35 super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
39 public Int8(final List<String> actualPath, final URI namespace,
40 final Date revision) {
41 super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
42 this.baseType = new Int8();
45 public Int8(final List<String> actualPath, final URI namespace,
46 final Date revision, final Byte defaultValue) {
47 super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
48 this.baseType = new Int8();
49 this.defaultValue = defaultValue;
52 public Int8(final List<String> actualPath, final URI namespace,
53 final Date revision, final List<RangeConstraint> rangeStatements,
54 final String units, final Byte defaultValue) {
55 super(actualPath, namespace, revision, name, description, rangeStatements, units);
56 this.baseType = new Int8();
57 this.defaultValue = defaultValue;
63 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
66 public IntegerTypeDefinition getBaseType() {
73 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
76 public Object getDefaultValue() {
81 public int hashCode() {
83 int result = super.hashCode();
84 result = prime * result
85 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
90 public boolean equals(Object obj) {
94 if (!super.equals(obj)) {
97 if (getClass() != obj.getClass()) {
100 Int8 other = (Int8) obj;
101 if (defaultValue == null) {
102 if (other.defaultValue != null) {
105 } else if (!defaultValue.equals(other.defaultValue)) {
112 public String toString() {
113 StringBuilder builder = new StringBuilder();
114 builder.append("Int8 [defaultValue=");
115 builder.append(defaultValue);
116 builder.append(", AbstractInteger=");
117 builder.append(super.toString());
119 return builder.toString();