Updated YANG Type definitions and documentation in YANG Model Utils.
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / model / util / Int16.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.model.util;\r
9 \r
10 import java.util.List;\r
11 \r
12 import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
13 import org.opendaylight.controller.model.api.type.RangeConstraint;\r
14 import org.opendaylight.controller.yang.common.QName;\r
15 \r
16 /**\r
17  * Implementation of Yang int16 built-in type. <br>\r
18  * int16 represents integer values between -32768 and 32767, inclusively. The\r
19  * Java counterpart of Yang int16 built-in type is {@link Short}.\r
20  * \r
21  * @see AbstractSignedInteger\r
22  */\r
23 public class Int16 extends AbstractSignedInteger {\r
24 \r
25     private static final QName name = BaseTypes.constructQName("int16");\r
26     private Short defaultValue = null;\r
27     private static final String description = \r
28             "int16  represents integer values between -32768 and 32767, inclusively.";\r
29 \r
30     public Int16() {\r
31         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");\r
32     }\r
33 \r
34     public Int16(final List<RangeConstraint> rangeStatements,\r
35             final String units, final Short defaultValue) {\r
36         super(name, description, rangeStatements, units);\r
37         this.defaultValue = defaultValue;\r
38     }\r
39 \r
40     @Override\r
41     public IntegerTypeDefinition getBaseType() {\r
42         return this;\r
43     }\r
44 \r
45     @Override\r
46     public Object getDefaultValue() {\r
47         return defaultValue;\r
48     }\r
49 \r
50     @Override\r
51     public int hashCode() {\r
52         final int prime = 31;\r
53         int result = super.hashCode();\r
54         result = prime * result\r
55                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
56         return result;\r
57     }\r
58 \r
59     @Override\r
60     public boolean equals(Object obj) {\r
61         if (this == obj) {\r
62             return true;\r
63         }\r
64         if (!super.equals(obj)) {\r
65             return false;\r
66         }\r
67         if (getClass() != obj.getClass()) {\r
68             return false;\r
69         }\r
70         Int16 other = (Int16) obj;\r
71         if (defaultValue == null) {\r
72             if (other.defaultValue != null) {\r
73                 return false;\r
74             }\r
75         } else if (!defaultValue.equals(other.defaultValue)) {\r
76             return false;\r
77         }\r
78         return true;\r
79     }\r
80 \r
81     @Override\r
82     public String toString() {\r
83         StringBuilder builder = new StringBuilder();\r
84         builder.append("Int16 [defaultValue=");\r
85         builder.append(defaultValue);\r
86         builder.append(", AbstractInteger=");\r
87         builder.append(super.toString());\r
88         builder.append("]");\r
89         return builder.toString();\r
90     }\r
91 }\r