f9c2aa3c90a15f41acb9700bae152aa953a237a9
[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     private final UnsignedIntegerTypeDefinition baseType;
34
35     private Uint64() {
36         super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
37         this.baseType = this;
38     }
39
40     public Uint64(final List<String> actualPath,
41             final URI namespace, final Date revision) {
42         super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
43         this.baseType = new Uint64();
44     }
45
46     public Uint64(final List<String> actualPath,
47             final URI namespace, final Date revision, final BigInteger defaultValue) {
48         super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
49         this.baseType = new Uint64();
50         this.defaultValue = defaultValue;
51     }
52
53     public Uint64(final List<String> actualPath,
54             final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
55             final String units, final BigInteger defaultValue) {
56         super(actualPath, namespace, revision, name, description, rangeStatements, units);
57         this.baseType = new Uint64();
58         this.defaultValue = defaultValue;
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see
65      * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
66      */
67     @Override
68     public UnsignedIntegerTypeDefinition getBaseType() {
69         return baseType;
70     }
71
72     /*
73      * (non-Javadoc)
74      *
75      * @see
76      * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
77      * ()
78      */
79     @Override
80     public Object getDefaultValue() {
81         return defaultValue;
82     }
83
84     @Override
85     public int hashCode() {
86         final int prime = 31;
87         int result = super.hashCode();
88         result = prime * result
89                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());
90         return result;
91     }
92
93     @Override
94     public boolean equals(Object obj) {
95         if (this == obj) {
96             return true;
97         }
98         if (!super.equals(obj)) {
99             return false;
100         }
101         if (getClass() != obj.getClass()) {
102             return false;
103         }
104         Uint64 other = (Uint64) obj;
105         if (defaultValue == null) {
106             if (other.defaultValue != null) {
107                 return false;
108             }
109         } else if (!defaultValue.equals(other.defaultValue)) {
110             return false;
111         }
112         return true;
113     }
114
115     @Override
116     public String toString() {
117         StringBuilder builder = new StringBuilder();
118         builder.append("Uint64 [defaultValue=");
119         builder.append(defaultValue);
120         builder.append(", AbstractInteger=");
121         builder.append(super.toString());
122         builder.append("]");
123         return builder.toString();
124     }
125 }