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