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