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