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