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