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