BUG-1276: fixed generated union constructor
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / 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.yangtools.yang.model.util;
9
10 import java.util.Collections;
11 import java.util.List;
12
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15 import org.opendaylight.yangtools.yang.model.api.Status;
16 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.yangtools.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 static final BooleanType INSTANCE = new BooleanType();
26     private static final SchemaPath PATH = SchemaPath.create(Collections.singletonList(BaseTypes.BOOLEAN_QNAME), true);
27     private static final String DESCRIPTION = "The boolean built-in type represents a boolean value.";
28     private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.5";
29     private static final String UNITS = "";
30
31     /**
32      * Default constructor with default value set to "false".
33      */
34     private BooleanType() {
35     }
36
37     /**
38      * Returns default instance of boolean built-in type.
39      * @return default instance of boolean built-in type.
40      */
41     public static BooleanType getInstance() {
42         return INSTANCE;
43     }
44
45     /*
46      * (non-Javadoc)
47      *
48      * @see
49      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
50      */
51     @Override
52     public BooleanTypeDefinition getBaseType() {
53         return null;
54     }
55
56     /*
57      * (non-Javadoc)
58      *
59      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
60      */
61     @Override
62     public String getUnits() {
63         return UNITS;
64     }
65
66     /*
67      * (non-Javadoc)
68      *
69      * @see
70      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
71      * ()
72      */
73     @Override
74     public Object getDefaultValue() {
75         return false;
76     }
77
78     /*
79      * (non-Javadoc)
80      *
81      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
82      */
83     @Override
84     public QName getQName() {
85         return BaseTypes.BOOLEAN_QNAME;
86     }
87
88     /*
89      * (non-Javadoc)
90      *
91      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
92      */
93     @Override
94     public SchemaPath getPath() {
95         return PATH;
96     }
97
98     /*
99      * (non-Javadoc)
100      *
101      * @see
102      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
103      */
104     @Override
105     public String getDescription() {
106         return DESCRIPTION;
107     }
108
109     /*
110      * (non-Javadoc)
111      *
112      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
113      */
114     @Override
115     public String getReference() {
116         return REFERENCE;
117     }
118
119     /*
120      * (non-Javadoc)
121      *
122      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
123      */
124     @Override
125     public Status getStatus() {
126         return Status.CURRENT;
127     }
128
129     @Override
130     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
131         return Collections.emptyList();
132     }
133
134     @Override
135     public String toString() {
136         StringBuilder builder = new StringBuilder();
137         builder.append("BooleanType [name=");
138         builder.append(BaseTypes.BOOLEAN_QNAME);
139         builder.append(", path=");
140         builder.append(PATH);
141         builder.append("]");
142         return builder.toString();
143     }
144 }