Deprecate Types.augmentableTypeFor()
[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 com.google.common.annotations.VisibleForTesting;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.mdsal.binding.model.api.ConcreteType;
16 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
17 import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
18 import org.opendaylight.mdsal.binding.model.api.Type;
19 import org.opendaylight.yangtools.yang.binding.Action;
20 import org.opendaylight.yangtools.yang.binding.Augmentable;
21 import org.opendaylight.yangtools.yang.binding.Augmentation;
22 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
23 import org.opendaylight.yangtools.yang.binding.ChildOf;
24 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
25 import org.opendaylight.yangtools.yang.binding.DataContainer;
26 import org.opendaylight.yangtools.yang.binding.DataObject;
27 import org.opendaylight.yangtools.yang.binding.DataRoot;
28 import org.opendaylight.yangtools.yang.binding.Identifiable;
29 import org.opendaylight.yangtools.yang.binding.Identifier;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31 import org.opendaylight.yangtools.yang.binding.InstanceNotification;
32 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
33 import org.opendaylight.yangtools.yang.binding.KeyedListAction;
34 import org.opendaylight.yangtools.yang.binding.KeyedListNotification;
35 import org.opendaylight.yangtools.yang.binding.Notification;
36 import org.opendaylight.yangtools.yang.binding.NotificationListener;
37 import org.opendaylight.yangtools.yang.binding.OpaqueObject;
38 import org.opendaylight.yangtools.yang.binding.RpcInput;
39 import org.opendaylight.yangtools.yang.binding.RpcOutput;
40 import org.opendaylight.yangtools.yang.binding.RpcService;
41 import org.opendaylight.yangtools.yang.binding.TypeObject;
42 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
43 import org.opendaylight.yangtools.yang.common.RpcResult;
44
45 public final class BindingTypes {
46
47     public static final ConcreteType BASE_IDENTITY = typeForClass(BaseIdentity.class);
48     public static final ConcreteType DATA_CONTAINER = typeForClass(DataContainer.class);
49     public static final ConcreteType DATA_OBJECT = typeForClass(DataObject.class);
50     public static final ConcreteType TYPE_OBJECT = typeForClass(TypeObject.class);
51     public static final ConcreteType DATA_ROOT = typeForClass(DataRoot.class);
52     public static final ConcreteType NOTIFICATION = typeForClass(Notification.class);
53     public static final ConcreteType NOTIFICATION_LISTENER = typeForClass(NotificationListener.class);
54     public static final ConcreteType RPC_INPUT = typeForClass(RpcInput.class);
55     public static final ConcreteType RPC_OUTPUT = typeForClass(RpcOutput.class);
56     public static final ConcreteType RPC_SERVICE = typeForClass(RpcService.class);
57
58     // This is an annotation, we are current just referencing the type
59     public static final JavaTypeName ROUTING_CONTEXT = JavaTypeName.create(RoutingContext.class);
60
61     @VisibleForTesting
62     static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class);
63     @VisibleForTesting
64     static final ConcreteType AUGMENTATION = typeForClass(Augmentation.class);
65     @VisibleForTesting
66     static final ConcreteType IDENTIFIABLE = typeForClass(Identifiable.class);
67     @VisibleForTesting
68     static final ConcreteType IDENTIFIER = typeForClass(Identifier.class);
69     @VisibleForTesting
70     static final ConcreteType INSTANCE_IDENTIFIER = typeForClass(InstanceIdentifier.class);
71
72     private static final ConcreteType ACTION = typeForClass(Action.class);
73     private static final ConcreteType CHILD_OF = typeForClass(ChildOf.class);
74     private static final ConcreteType CHOICE_IN = typeForClass(ChoiceIn.class);
75     private static final ConcreteType INSTANCE_NOTIFICATION = typeForClass(InstanceNotification.class);
76     private static final ConcreteType KEYED_INSTANCE_IDENTIFIER = typeForClass(KeyedInstanceIdentifier.class);
77     private static final ConcreteType KEYED_LIST_ACTION = typeForClass(KeyedListAction.class);
78     private static final ConcreteType KEYED_LIST_NOTIFICATION = typeForClass(KeyedListNotification.class);
79     private static final ConcreteType OPAQUE_OBJECT = typeForClass(OpaqueObject.class);
80     private static final ConcreteType RPC_RESULT = typeForClass(RpcResult.class);
81
82     private BindingTypes() {
83
84     }
85
86     /**
87      * Type specializing {@link Action} for a particular type.
88      *
89      * @param parent Type of parent defining the action
90      * @param input Type input type
91      * @param output Type output type
92      * @return A parameterized type corresponding to {@code Action<Parent, Input, Output>}
93      * @throws NullPointerException if any argument is is null
94      */
95     public static ParameterizedType action(final Type parent, final Type input, final Type output) {
96         return parameterizedTypeFor(ACTION, instanceIdentifier(parent), input, output);
97     }
98
99     /**
100      * Type specializing {@link KeyedListAction} for a particular type.
101      *
102      * @param parent Type of parent defining the action
103      * @param keyType Type of parent's key
104      * @param input Type input type
105      * @param output Type output type
106      * @return A parameterized type corresponding to {@code KeyedListAction<ParentKey, Parent, Input, Output>}
107      * @throws NullPointerException if any argument is is null
108      */
109     public static ParameterizedType keyedListAction(final Type parent, final Type keyType, final Type input,
110             final Type output) {
111         return parameterizedTypeFor(KEYED_LIST_ACTION, keyType, parent, input, output);
112     }
113
114     /**
115      * Type specializing {@link InstanceNotification} for a particular type.
116      *
117      * @param parent Type of parent defining the notification
118      * @return A parameterized type corresponding to {@code InstanceNotification<Parent>}
119      * @throws NullPointerException if {@code parent} is is null
120      */
121     public static ParameterizedType instanceNotification(final Type concreteType, final Type parent) {
122         return parameterizedTypeFor(INSTANCE_NOTIFICATION, concreteType, parent);
123     }
124
125     /**
126      * Type specializing {@link InstanceNotification} for a particular type.
127      *
128      * @param parent Type of parent defining the notification
129      * @param keyType Type of parent's key
130      * @return A parameterized type corresponding to {@code KeyedInstanceNotification<ParentKey, Parent>}
131      * @throws NullPointerException if any argument is is null
132      */
133     public static ParameterizedType keyedListNotification(final Type concreteType, final Type parent,
134             final Type keyType) {
135         return parameterizedTypeFor(KEYED_LIST_NOTIFICATION, concreteType, parent, keyType);
136     }
137
138     /**
139      * Specialize {@link Augmentable} for a particular type.
140      *
141      * @param type Type for which to specialize
142      * @return A parameterized type corresponding to {@code Augmentable<Type>}
143      * @throws NullPointerException if {@code type} is null
144      */
145     public static @NonNull ParameterizedType augmentable(final Type type) {
146         return parameterizedTypeFor(AUGMENTABLE, type);
147     }
148
149     /**
150      * Specialize {@link ChildOf} for a particular type.
151      *
152      * @param type Type for which to specialize
153      * @return A parameterized type corresponding to {@code ChildOf<Type>}
154      * @throws NullPointerException if {@code type} is null
155      */
156     public static ParameterizedType childOf(final Type type) {
157         return parameterizedTypeFor(CHILD_OF, type);
158     }
159
160     /**
161      * Type specializing {@link ChoiceIn} for a particular type.
162      *
163      * @param type Type for which to specialize
164      * @return A parameterized type corresponding to {@code ChoiceIn<Type>}
165      * @throws NullPointerException if {@code type} is null
166      */
167     public static ParameterizedType choiceIn(final Type type) {
168         return parameterizedTypeFor(CHOICE_IN, type);
169     }
170
171     /**
172      * Type specializing {@link Identifier} for a particular type.
173      *
174      * @param type Type for which to specialize
175      * @return A parameterized type corresponding to {@code Identifier<Type>}
176      * @throws NullPointerException if {@code type} is null
177      */
178     public static ParameterizedType identifier(final Type type) {
179         return parameterizedTypeFor(IDENTIFIER, type);
180     }
181
182     /**
183      * Type specializing {@link Identifiable} for a particular type.
184      *
185      * @param type Type for which to specialize
186      * @return A parameterized type corresponding to {@code Identifiable<Type>}
187      * @throws NullPointerException if {@code type} is null
188      */
189     public static ParameterizedType identifiable(final Type type) {
190         return parameterizedTypeFor(IDENTIFIABLE, type);
191     }
192
193     /**
194      * Type specializing {@link InstanceIdentifier} for a particular type.
195      *
196      * @param type Type for which to specialize
197      * @return A parameterized type corresponding to {@code InstanceIdentifier<Type>}
198      * @throws NullPointerException if {@code type} is null
199      */
200     public static ParameterizedType instanceIdentifier(final Type type) {
201         return parameterizedTypeFor(INSTANCE_IDENTIFIER, type);
202     }
203
204     /**
205      * Type specializing {@link KeyedInstanceIdentifier} for a particular type.
206      *
207      * @param type Type for which to specialize
208      * @param keyType Type of key
209      * @return A parameterized type corresponding to {@code KeyedInstanceIdentifier<Type, KeyType>}
210      * @throws NullPointerException if any argument is is null
211      */
212     public static ParameterizedType keyedInstanceIdentifier(final Type type, final Type keyType) {
213         return parameterizedTypeFor(KEYED_INSTANCE_IDENTIFIER, type, keyType);
214     }
215
216     /**
217      * Type specializing {@link OpaqueObject} for a particular type.
218      *
219      * @param type Type for which to specialize
220      * @return A parameterized type corresponding to {@code OpaqueObject<Type>}
221      * @throws NullPointerException if {@code type} is null
222      */
223     public static ParameterizedType opaqueObject(final Type type) {
224         return parameterizedTypeFor(OPAQUE_OBJECT, type);
225     }
226
227     /**
228      * Type specializing {@link RpcResult} for a particular type.
229      *
230      * @param type Type for which to specialize
231      * @return A parameterized type corresponding to {@code RpcResult<Type>}
232      * @throws NullPointerException if {@code type} is null
233      */
234     public static ParameterizedType rpcResult(final Type type) {
235         return parameterizedTypeFor(RPC_RESULT, type);
236     }
237 }