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