Merge "Bumped version of Maven YANG tools to 0.5.1-SNAPSHOT"
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / IdentityType.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.Collections;
11 import java.util.List;
12
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.SchemaPath;
15 import org.opendaylight.controller.yang.model.api.Status;
16 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.controller.yang.model.api.type.IdentityTypeDefinition;
18
19 /**
20  * The <code>default</code> implementation of Identity Type Definition interface.
21  * 
22  * @see IdentityTypeDefinition
23  */
24 public class IdentityType implements IdentityTypeDefinition {
25
26     private final QName name = BaseTypes.constructQName("identity");
27     private final SchemaPath path = BaseTypes.schemaPath(name);
28     private final String description = "The 'identity' statement is used to define a new " +
29                 "globally unique, abstract, and untyped identity.";
30     private final String reference = "https://tools.ietf.org/html/rfc6020#section-7.16";
31
32     private String units = "";
33     private final QName identityName;
34
35     public IdentityType(QName identityName) {
36         super();
37         this.identityName = identityName;
38     }
39
40     /*
41      * (non-Javadoc)
42      * 
43      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
44      */
45     @Override
46     public IdentityTypeDefinition getBaseType() {
47         return this;
48     }
49
50     /*
51      * (non-Javadoc)
52      * 
53      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
54      */
55     @Override
56     public String getUnits() {
57         return units;
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 this;
68     }
69
70     /*
71      * (non-Javadoc)
72      * 
73      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
74      */
75     @Override
76     public QName getQName() {
77         // TODO Auto-generated method stub
78         return null;
79     }
80
81     /*
82      * (non-Javadoc)
83      * 
84      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
85      */
86     @Override
87     public SchemaPath getPath() {
88         return path;
89     }
90
91     /*
92      * (non-Javadoc)
93      * 
94      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
95      */
96     @Override
97     public String getDescription() {
98         return description;
99     }
100
101     /*
102      * (non-Javadoc)
103      * 
104      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
105      */
106     @Override
107     public String getReference() {
108         return reference;
109     }
110
111     /*
112      * (non-Javadoc)
113      * 
114      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
115      */
116     @Override
117     public Status getStatus() {
118         return Status.CURRENT;
119     }
120
121     @Override
122     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
123         return Collections.emptyList();
124     }
125
126     /*
127      * (non-Javadoc)
128      * 
129      * @see
130      * org.opendaylight.controller.yang.model.base.type.api.IdentityTypeDefinition#getIdentityName
131      * ()
132      */
133     @Override
134     public QName getIdentityName() {
135         return identityName;
136     }
137
138     @Override
139     public int hashCode() {
140         final int prime = 31;
141         int result = 1;
142         result = prime * result
143                 + ((description == null) ? 0 : description.hashCode());
144         result = prime * result
145                 + ((identityName == null) ? 0 : identityName.hashCode());
146         result = prime * result + ((name == null) ? 0 : name.hashCode());
147         result = prime * result + ((path == null) ? 0 : path.hashCode());
148         result = prime * result
149                 + ((reference == null) ? 0 : reference.hashCode());
150         result = prime * result + ((units == null) ? 0 : units.hashCode());
151         return result;
152     }
153
154     @Override
155     public boolean equals(Object obj) {
156         if (this == obj) {
157             return true;
158         }
159         if (obj == null) {
160             return false;
161         }
162         if (getClass() != obj.getClass()) {
163             return false;
164         }
165         IdentityType other = (IdentityType) obj;
166         if (description == null) {
167             if (other.description != null) {
168                 return false;
169             }
170         } else if (!description.equals(other.description)) {
171             return false;
172         }
173         if (identityName == null) {
174             if (other.identityName != null) {
175                 return false;
176             }
177         } else if (!identityName.equals(other.identityName)) {
178             return false;
179         }
180         if (name == null) {
181             if (other.name != null) {
182                 return false;
183             }
184         } else if (!name.equals(other.name)) {
185             return false;
186         }
187         if (path == null) {
188             if (other.path != null) {
189                 return false;
190             }
191         } else if (!path.equals(other.path)) {
192             return false;
193         }
194         if (reference == null) {
195             if (other.reference != null) {
196                 return false;
197             }
198         } else if (!reference.equals(other.reference)) {
199             return false;
200         }
201         if (units == null) {
202             if (other.units != null) {
203                 return false;
204             }
205         } else if (!units.equals(other.units)) {
206             return false;
207         }
208         return true;
209     }
210
211     @Override
212     public String toString() {
213         StringBuilder builder = new StringBuilder();
214         builder.append("IdentityType [name=");
215         builder.append(name);
216         builder.append(", path=");
217         builder.append(path);
218         builder.append(", description=");
219         builder.append(description);
220         builder.append(", reference=");
221         builder.append(reference);
222         builder.append(", units=");
223         builder.append(units);
224         builder.append(", identityName=");
225         builder.append(identityName);
226         builder.append("]");
227         return builder.toString();
228     }
229 }