9b0c66ba4474a1c0f91d5ce5e9c07013178780ec
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / BindingTypes.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.mdsal.binding.model.util;
9
10 import static org.opendaylight.mdsal.binding.model.util.Types.parameterizedTypeFor;
11 import static org.opendaylight.mdsal.binding.model.util.Types.typeForClass;
12
13 import org.opendaylight.mdsal.binding.model.api.ConcreteType;
14 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
15 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
16 import org.opendaylight.mdsal.binding.model.api.Type;
17 import org.opendaylight.yangtools.yang.binding.Action;
18 import org.opendaylight.yangtools.yang.binding.Augmentable;
19 import org.opendaylight.yangtools.yang.binding.Augmentation;
20 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
21 import org.opendaylight.yangtools.yang.binding.ChildOf;
22 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
23 import org.opendaylight.yangtools.yang.binding.DataContainer;
24 import org.opendaylight.yangtools.yang.binding.DataObject;
25 import org.opendaylight.yangtools.yang.binding.DataRoot;
26 import org.opendaylight.yangtools.yang.binding.Identifiable;
27 import org.opendaylight.yangtools.yang.binding.Identifier;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 import org.opendaylight.yangtools.yang.binding.Notification;
30 import org.opendaylight.yangtools.yang.binding.NotificationListener;
31 import org.opendaylight.yangtools.yang.binding.RpcInput;
32 import org.opendaylight.yangtools.yang.binding.RpcOutput;
33 import org.opendaylight.yangtools.yang.binding.RpcService;
34 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
35 import org.opendaylight.yangtools.yang.common.RpcResult;
36
37 public final class BindingTypes {
38
39     public static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class);
40     public static final ConcreteType AUGMENTATION = typeForClass(Augmentation.class);
41     public static final ConcreteType BASE_IDENTITY = typeForClass(BaseIdentity.class);
42     public static final ConcreteType DATA_CONTAINER = typeForClass(DataContainer.class);
43     public static final ConcreteType DATA_OBJECT = typeForClass(DataObject.class);
44     public static final ConcreteType DATA_ROOT = typeForClass(DataRoot.class);
45     public static final ConcreteType IDENTIFIABLE = typeForClass(Identifiable.class);
46     public static final ConcreteType IDENTIFIER = typeForClass(Identifier.class);
47     public static final ConcreteType INSTANCE_IDENTIFIER = typeForClass(InstanceIdentifier.class);
48     public static final ConcreteType NOTIFICATION = typeForClass(Notification.class);
49     public static final ConcreteType NOTIFICATION_LISTENER = typeForClass(NotificationListener.class);
50     public static final ConcreteType RPC_INPUT = typeForClass(RpcInput.class);
51     public static final ConcreteType RPC_OUTPUT = typeForClass(RpcOutput.class);
52     public static final ConcreteType RPC_SERVICE = typeForClass(RpcService.class);
53
54     // This is an annotation, we are current just referencing the type
55     public static final JavaTypeName ROUTING_CONTEXT = JavaTypeName.create(RoutingContext.class);
56
57     private static final ConcreteType ACTION = typeForClass(Action.class);
58     private static final ConcreteType CHILD_OF = typeForClass(ChildOf.class);
59     private static final ConcreteType CHOICE_IN = typeForClass(ChoiceIn.class);
60     private static final ConcreteType RPC_RESULT = typeForClass(RpcResult.class);
61
62     private BindingTypes() {
63
64     }
65
66     /**
67      * Type specializing {@link Action} for a particular type.
68      *
69      * @param parent Type of parent defining the action
70      * @param input Type input type
71      * @param output Type output type
72      * @return A parameterized type corresponding to {@code Action<Parent, Input, Output>}
73      * @throws NullPointerException if any argument is is null
74      */
75     public static ParameterizedType action(final Type parent, final Type input, final Type output) {
76         return parameterizedTypeFor(ACTION, parent, input, output);
77     }
78
79     /**
80      * Specialize {@link Augmentable} for a particular type.
81      *
82      * @param type Type for which to specialize
83      * @return A parameterized type corresponding to {@code Augmentable<Type>}
84      * @throws NullPointerException if {@code type} is null
85      */
86     public static ParameterizedType augmentable(final Type type) {
87         return parameterizedTypeFor(AUGMENTABLE, type);
88     }
89
90     /**
91      * Specialize {@link ChildOf} for a particular type.
92      *
93      * @param type Type for which to specialize
94      * @return A parameterized type corresponding to {@code ChildOf<Type>}
95      * @throws NullPointerException if {@code type} is null
96      */
97     public static ParameterizedType childOf(final Type type) {
98         return parameterizedTypeFor(CHILD_OF, type);
99     }
100
101     /**
102      * Type specializing {@link ChoiceIn} for a particular type.
103      *
104      * @param type Type for which to specialize
105      * @return A parameterized type corresponding to {@code ChoiceIn<Type>}
106      * @throws NullPointerException if {@code type} is null
107      */
108     public static ParameterizedType choiceIn(final Type type) {
109         return parameterizedTypeFor(CHOICE_IN, type);
110     }
111
112     /**
113      * Type specializing {@link Identifier} for a particular type.
114      *
115      * @param type Type for which to specialize
116      * @return A parameterized type corresponding to {@code Identifier<Type>}
117      * @throws NullPointerException if {@code type} is null
118      */
119     public static ParameterizedType identifier(final Type type) {
120         return parameterizedTypeFor(IDENTIFIER, type);
121     }
122
123     /**
124      * Type specializing {@link Identifiable} for a particular type.
125      *
126      * @param type Type for which to specialize
127      * @return A parameterized type corresponding to {@code Identifiable<Type>}
128      * @throws NullPointerException if {@code type} is null
129      */
130     public static ParameterizedType identifiable(final Type type) {
131         return parameterizedTypeFor(IDENTIFIABLE, type);
132     }
133
134     /**
135      * Type specializing {@link InstanceIdentifier} for a particular type.
136      *
137      * @param type Type for which to specialize
138      * @return A parameterized type corresponding to {@code InstanceIdentifier<Type>}
139      * @throws NullPointerException if {@code type} is null
140      */
141     public static ParameterizedType instanceIdentifier(final Type type) {
142         return parameterizedTypeFor(INSTANCE_IDENTIFIER, type);
143     }
144
145     /**
146      * Type specializing {@link RpcResult} for a particular type.
147      *
148      * @param type Type for which to specialize
149      * @return A parameterized type corresponding to {@code RpcResult<Type>}
150      * @throws NullPointerException if {@code type} is null
151      */
152     public static ParameterizedType rpcResult(final Type type) {
153         return parameterizedTypeFor(RPC_RESULT, type);
154     }
155 }