Introduce model.util.type package
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / BaseTypes.java
1 /*
2  * Copyright (c) 2015 Pantheon Technologies s.r.o. 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.type;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
12 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
13 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
14 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
15 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
16 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
17 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
18 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
19
20 /**
21  * Utility access methods for creating and accessing YANG base type definitions. YANG types come in two basic variants,
22  * depending on whether they fully define their base instance or model input is required to fully-form the type.
23  *
24  * The following types have their base type fully specified and are exposed as appropriate TypeDefinition sub-interfaces:
25  * <ul>
26  *     <li>boolean</li>
27  *     <li>empty</li>
28  *     <li>binary</li>
29  *     <li>int{8,16,32,64}</li>
30  *     <li>string</li>
31  *     <li>uint{8,16,32,64}</li>
32  * </ul>
33  *
34  * The following types require additional specification in the model and are exposed by means of a specialized
35  * {@link TypeBuilder}s for each type:
36  * <ul>
37  *    <li>decimal64</li>
38  *    <li>instance-identifier</li>
39  *    <li>enumeration</li>
40  *    <li>identityref</li>
41  *    <li>leafref</li>
42  *    <li>union</li>
43  * </ul>
44  */
45 @Beta
46 public final class BaseTypes {
47     private BaseTypes() {
48         throw new UnsupportedOperationException();
49     }
50
51     public static BinaryTypeDefinition binaryType() {
52         return BaseBinaryType.INSTANCE;
53     }
54
55     public static BitsTypeBuilder bitsTypeBuilder(final SchemaPath path) {
56         return new BitsTypeBuilder(path);
57     }
58
59     public static BooleanTypeDefinition booleanType() {
60         return BaseBooleanType.INSTANCE;
61     }
62
63     public static DecimalTypeBuilder decimalTypeBuilder(final SchemaPath path) {
64         return new DecimalTypeBuilder(path);
65     }
66
67     public static EmptyTypeDefinition emptyType() {
68         return BaseEmptyType.INSTANCE;
69     }
70
71     public static EnumerationTypeBuilder enumerationTypeBuilder(final SchemaPath path) {
72         return new EnumerationTypeBuilder(path);
73     }
74
75     public static IdentityrefTypeBuilder identityrefTypeBuilder(final SchemaPath path) {
76         return new IdentityrefTypeBuilder(path);
77     }
78
79     public static InstanceIdentifierTypeDefinition instanceIdentifierType() {
80         return BaseInstanceIdentifierType.INSTANCE;
81     }
82
83     public static IntegerTypeDefinition int8Type() {
84         return BaseInt8Type.INSTANCE;
85     }
86
87     public static IntegerTypeDefinition int16Type() {
88         return BaseInt16Type.INSTANCE;
89     }
90
91     public static IntegerTypeDefinition int32Type() {
92         return BaseInt32Type.INSTANCE;
93     }
94
95     public static IntegerTypeDefinition int64Type() {
96         return BaseInt64Type.INSTANCE;
97     }
98
99     public static LeafrefTypeBuilder leafrefTypeBuilder(final SchemaPath path) {
100         return new LeafrefTypeBuilder(path);
101     }
102
103     public static StringTypeDefinition stringType() {
104         return BaseStringType.INSTANCE;
105     }
106
107     public static UnionTypeBuilder unionTypeBuilder(final SchemaPath path) {
108         return new UnionTypeBuilder(path);
109     }
110
111     public static UnsignedIntegerTypeDefinition uint8Type() {
112         return BaseUint8Type.INSTANCE;
113     }
114
115     public static UnsignedIntegerTypeDefinition uint16Type() {
116         return BaseUint16Type.INSTANCE;
117     }
118
119     public static UnsignedIntegerTypeDefinition uint32Type() {
120         return BaseUint32Type.INSTANCE;
121     }
122
123     public static UnsignedIntegerTypeDefinition uint64Type() {
124         return BaseUint64Type.INSTANCE;
125     }
126 }