Initial opendaylight infrastructure commit!!
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / model / util / BooleanType.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.BooleanTypeDefinition;\r
14 import org.opendaylight.controller.yang.common.QName;\r
15 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
16 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
17 import org.opendaylight.controller.yang.model.api.Status;\r
18 \r
19 public class BooleanType implements BooleanTypeDefinition {\r
20 \r
21     private final QName name = BaseTypes.constructQName("boolean");\r
22     private final SchemaPath path = BaseTypes.schemaPath(name);\r
23     private final String description = "";\r
24     private final String reference = "";\r
25 \r
26     private final Boolean defaultValue;\r
27     private String units = "";\r
28 \r
29     /**\r
30      * Default constructor with default value set to "false".\r
31      */\r
32     public BooleanType() {\r
33         super();\r
34         defaultValue = false;\r
35     }\r
36 \r
37     /**\r
38      * \r
39      * \r
40      * @param defaultValue\r
41      */\r
42     public BooleanType(final Boolean defaultValue) {\r
43         super();\r
44         this.defaultValue = defaultValue;\r
45     }\r
46 \r
47     /**\r
48      * \r
49      * \r
50      * @param defaultValue\r
51      * @param units\r
52      */\r
53     public BooleanType(final Boolean defaultValue, final String units) {\r
54         super();\r
55         this.defaultValue = defaultValue;\r
56         this.units = units;\r
57     }\r
58 \r
59     /*\r
60      * (non-Javadoc)\r
61      * \r
62      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
63      */\r
64     @Override\r
65     public BooleanTypeDefinition getBaseType() {\r
66         return this;\r
67     }\r
68 \r
69     /*\r
70      * (non-Javadoc)\r
71      * \r
72      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
73      */\r
74     @Override\r
75     public String getUnits() {\r
76         return units;\r
77     }\r
78 \r
79     /*\r
80      * (non-Javadoc)\r
81      * \r
82      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
83      */\r
84     @Override\r
85     public Object getDefaultValue() {\r
86         return defaultValue;\r
87     }\r
88 \r
89     /*\r
90      * (non-Javadoc)\r
91      * \r
92      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
93      */\r
94     @Override\r
95     public QName getQName() {\r
96         return name;\r
97     }\r
98 \r
99     /*\r
100      * (non-Javadoc)\r
101      * \r
102      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
103      */\r
104     @Override\r
105     public SchemaPath getPath() {\r
106         return path;\r
107     }\r
108 \r
109     /*\r
110      * (non-Javadoc)\r
111      * \r
112      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
113      */\r
114     @Override\r
115     public String getDescription() {\r
116         return description;\r
117     }\r
118 \r
119     /*\r
120      * (non-Javadoc)\r
121      * \r
122      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
123      */\r
124     @Override\r
125     public String getReference() {\r
126         return reference;\r
127     }\r
128 \r
129     /*\r
130      * (non-Javadoc)\r
131      * \r
132      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
133      */\r
134     @Override\r
135     public Status getStatus() {\r
136         return Status.CURRENT;\r
137     }\r
138 \r
139     @Override\r
140     public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
141         return Collections.emptyList();\r
142     }\r
143 \r
144     @Override\r
145     public int hashCode() {\r
146         final int prime = 31;\r
147         int result = 1;\r
148         result = prime * result\r
149                 + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
150         result = prime * result\r
151                 + ((description == null) ? 0 : description.hashCode());\r
152         result = prime * result + ((name == null) ? 0 : name.hashCode());\r
153         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
154         result = prime * result\r
155                 + ((reference == null) ? 0 : reference.hashCode());\r
156         result = prime * result + ((units == null) ? 0 : units.hashCode());\r
157         return result;\r
158     }\r
159 \r
160     @Override\r
161     public boolean equals(Object obj) {\r
162         if (this == obj) {\r
163             return true;\r
164         }\r
165         if (obj == null) {\r
166             return false;\r
167         }\r
168         if (getClass() != obj.getClass()) {\r
169             return false;\r
170         }\r
171         BooleanType other = (BooleanType) obj;\r
172         if (defaultValue == null) {\r
173             if (other.defaultValue != null) {\r
174                 return false;\r
175             }\r
176         } else if (!defaultValue.equals(other.defaultValue)) {\r
177             return false;\r
178         }\r
179         if (description == null) {\r
180             if (other.description != null) {\r
181                 return false;\r
182             }\r
183         } else if (!description.equals(other.description)) {\r
184             return false;\r
185         }\r
186         if (name == null) {\r
187             if (other.name != null) {\r
188                 return false;\r
189             }\r
190         } else if (!name.equals(other.name)) {\r
191             return false;\r
192         }\r
193         if (path == null) {\r
194             if (other.path != null) {\r
195                 return false;\r
196             }\r
197         } else if (!path.equals(other.path)) {\r
198             return false;\r
199         }\r
200         if (reference == null) {\r
201             if (other.reference != null) {\r
202                 return false;\r
203             }\r
204         } else if (!reference.equals(other.reference)) {\r
205             return false;\r
206         }\r
207         if (units == null) {\r
208             if (other.units != null) {\r
209                 return false;\r
210             }\r
211         } else if (!units.equals(other.units)) {\r
212             return false;\r
213         }\r
214         return true;\r
215     }\r
216 \r
217     @Override\r
218     public String toString() {\r
219         StringBuilder builder = new StringBuilder();\r
220         builder.append("BooleanType [name=");\r
221         builder.append(name);\r
222         builder.append(", path=");\r
223         builder.append(path);\r
224         builder.append(", description=");\r
225         builder.append(description);\r
226         builder.append(", reference=");\r
227         builder.append(reference);\r
228         builder.append(", defaultValue=");\r
229         builder.append(defaultValue);\r
230         builder.append(", units=");\r
231         builder.append(units);\r
232         builder.append("]");\r
233         return builder.toString();\r
234     }\r
235 }\r