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 / Int64.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 int64 built-in type. <br>\r
18  * int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively. \r
19  * The Java counterpart of Yang int64 built-in type is\r
20  * {@link Long}.\r
21  *\r
22  */\r
23 public class Int64 extends AbstractSignedInteger {\r
24 \r
25     private static final QName name = BaseTypes.constructQName("int64");\r
26     private Long defaultValue = null;\r
27     private static final String description = \r
28             "int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";\r
29 \r
30     public Int64() {\r
31         super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");\r
32     }\r
33 \r
34     public Int64(final Long defaultValue) {\r
35         super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");\r
36         this.defaultValue = defaultValue;\r
37     }\r
38 \r
39     public Int64(final List<RangeConstraint> rangeStatements,\r
40             final String units, final Long defaultValue) {\r
41         super(name, description, rangeStatements, units);\r
42         this.defaultValue = defaultValue;\r
43     }\r
44 \r
45     /*\r
46      * (non-Javadoc)\r
47      * \r
48      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
49      */\r
50     @Override\r
51     public IntegerTypeDefinition getBaseType() {\r
52         return this;\r
53     }\r
54 \r
55     /*\r
56      * (non-Javadoc)\r
57      * \r
58      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
59      */\r
60     @Override\r
61     public Object getDefaultValue() {\r
62         return defaultValue;\r
63     }\r
64 \r
65     @Override\r
66     public int hashCode() {\r
67         final int prime = 31;\r
68         int result = super.hashCode();\r
69         result = prime * result\r
70                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
71         return result;\r
72     }\r
73 \r
74     @Override\r
75     public boolean equals(Object obj) {\r
76         if (this == obj) {\r
77             return true;\r
78         }\r
79         if (!super.equals(obj)) {\r
80             return false;\r
81         }\r
82         if (getClass() != obj.getClass()) {\r
83             return false;\r
84         }\r
85         Int64 other = (Int64) obj;\r
86         if (defaultValue == null) {\r
87             if (other.defaultValue != null) {\r
88                 return false;\r
89             }\r
90         } else if (!defaultValue.equals(other.defaultValue)) {\r
91             return false;\r
92         }\r
93         return true;\r
94     }\r
95 \r
96     @Override\r
97     public String toString() {\r
98         StringBuilder builder = new StringBuilder();\r
99         builder.append("Int64 [defaultValue=");\r
100         builder.append(defaultValue);\r
101         builder.append(", AbstractInteger=");\r
102         builder.append(super.toString());\r
103         builder.append("]");\r
104         return builder.toString();\r
105     }\r
106 }\r