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