Refactored SchemaPath for yang java types. Fixed SchemaPath for augmented nodes types.
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / Int16.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.yang.model.util;
9
10 import java.util.List;
11
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;
16
17 /**
18  * Implementation of Yang int16 built-in type. <br>
19  * int16 represents integer values between -32768 and 32767, inclusively. The
20  * Java counterpart of Yang int16 built-in type is {@link Short}.
21  *
22  * @see AbstractSignedInteger
23  */
24 public final class Int16 extends AbstractSignedInteger {
25
26     private static final QName name = BaseTypes.constructQName("int16");
27     private Short defaultValue = null;
28     private static final String description = "int16  represents integer values between -32768 and 32767, inclusively.";
29     private final IntegerTypeDefinition baseType;
30
31     private Int16() {
32         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
33         this.baseType = this;
34     }
35
36     public Int16(final SchemaPath path) {
37         super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
38         this.baseType = new Int16();
39
40     }
41
42     public Int16(final SchemaPath path,
43             final List<RangeConstraint> rangeStatements, final String units,
44             final Short defaultValue) {
45         super(path, name, description, rangeStatements, units);
46         this.defaultValue = defaultValue;
47         this.baseType = new Int16();
48     }
49
50     @Override
51     public IntegerTypeDefinition getBaseType() {
52         return baseType;
53     }
54
55     @Override
56     public Object getDefaultValue() {
57         return defaultValue;
58     }
59
60     @Override
61     public int hashCode() {
62         final int prime = 31;
63         int result = super.hashCode();
64         result = prime * result
65                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
66         return result;
67     }
68
69     @Override
70     public boolean equals(Object obj) {
71         if (this == obj) {
72             return true;
73         }
74         if (!super.equals(obj)) {
75             return false;
76         }
77         if (getClass() != obj.getClass()) {
78             return false;
79         }
80         Int16 other = (Int16) obj;
81         if (defaultValue == null) {
82             if (other.defaultValue != null) {
83                 return false;
84             }
85         } else if (!defaultValue.equals(other.defaultValue)) {
86             return false;
87         }
88         return true;
89     }
90
91     @Override
92     public String toString() {
93         StringBuilder builder = new StringBuilder();
94         builder.append("Int16 [defaultValue=");
95         builder.append(defaultValue);
96         builder.append(", AbstractInteger=");
97         builder.append(super.toString());
98         builder.append("]");
99         return builder.toString();
100     }
101 }