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