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