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