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.";
33 public Int8(final List<String> actualPath, final URI namespace,
34 final Date revision) {
35 super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
38 public Int8(final List<String> actualPath, final URI namespace,
39 final Date revision, final Byte defaultValue) {
40 super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
41 this.defaultValue = defaultValue;
44 public Int8(final List<String> actualPath, final URI namespace,
45 final Date revision, final List<RangeConstraint> rangeStatements,
46 final String units, final Byte defaultValue) {
47 super(actualPath, namespace, revision, name, description, rangeStatements, units);
48 this.defaultValue = defaultValue;
54 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
57 public IntegerTypeDefinition getBaseType() {
64 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
67 public Object getDefaultValue() {
72 public int hashCode() {
74 int result = super.hashCode();
75 result = prime * result
76 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
81 public boolean equals(Object obj) {
85 if (!super.equals(obj)) {
88 if (getClass() != obj.getClass()) {
91 Int8 other = (Int8) obj;
92 if (defaultValue == null) {
93 if (other.defaultValue != null) {
96 } else if (!defaultValue.equals(other.defaultValue)) {
103 public String toString() {
104 StringBuilder builder = new StringBuilder();
105 builder.append("Int8 [defaultValue=");
106 builder.append(defaultValue);
107 builder.append(", AbstractInteger=");
108 builder.append(super.toString());
110 return builder.toString();