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