X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fmdsal-binding-generator-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fmodel%2Futil%2FBindingTypes.java;h=250ca03e228b87583f2d9ed0dc7ae13bf07537d0;hb=bfad05606e2defc1a376921f1b82781abb4a233b;hp=9b0c66ba4474a1c0f91d5ce5e9c07013178780ec;hpb=f343810d045cd28301fb95cffbd1ba8fa7db76c1;p=mdsal.git diff --git a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/BindingTypes.java b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/BindingTypes.java index 9b0c66ba44..250ca03e22 100644 --- a/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/BindingTypes.java +++ b/binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/BindingTypes.java @@ -10,6 +10,8 @@ package org.opendaylight.mdsal.binding.model.util; import static org.opendaylight.mdsal.binding.model.util.Types.parameterizedTypeFor; import static org.opendaylight.mdsal.binding.model.util.Types.typeForClass; +import com.google.common.annotations.VisibleForTesting; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.model.api.ConcreteType; import org.opendaylight.mdsal.binding.model.api.JavaTypeName; import org.opendaylight.mdsal.binding.model.api.ParameterizedType; @@ -26,27 +28,31 @@ import org.opendaylight.yangtools.yang.binding.DataRoot; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceNotification; +import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.KeyedListAction; +import org.opendaylight.yangtools.yang.binding.KeyedListNotification; import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.binding.OpaqueObject; import org.opendaylight.yangtools.yang.binding.RpcInput; import org.opendaylight.yangtools.yang.binding.RpcOutput; import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.binding.TypeObject; import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; public final class BindingTypes { - public static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class); - public static final ConcreteType AUGMENTATION = typeForClass(Augmentation.class); public static final ConcreteType BASE_IDENTITY = typeForClass(BaseIdentity.class); public static final ConcreteType DATA_CONTAINER = typeForClass(DataContainer.class); public static final ConcreteType DATA_OBJECT = typeForClass(DataObject.class); + public static final ConcreteType TYPE_OBJECT = typeForClass(TypeObject.class); public static final ConcreteType DATA_ROOT = typeForClass(DataRoot.class); - public static final ConcreteType IDENTIFIABLE = typeForClass(Identifiable.class); - public static final ConcreteType IDENTIFIER = typeForClass(Identifier.class); - public static final ConcreteType INSTANCE_IDENTIFIER = typeForClass(InstanceIdentifier.class); public static final ConcreteType NOTIFICATION = typeForClass(Notification.class); public static final ConcreteType NOTIFICATION_LISTENER = typeForClass(NotificationListener.class); + public static final ConcreteType QNAME = typeForClass(QName.class); public static final ConcreteType RPC_INPUT = typeForClass(RpcInput.class); public static final ConcreteType RPC_OUTPUT = typeForClass(RpcOutput.class); public static final ConcreteType RPC_SERVICE = typeForClass(RpcService.class); @@ -54,9 +60,25 @@ public final class BindingTypes { // This is an annotation, we are current just referencing the type public static final JavaTypeName ROUTING_CONTEXT = JavaTypeName.create(RoutingContext.class); + @VisibleForTesting + static final ConcreteType AUGMENTABLE = typeForClass(Augmentable.class); + @VisibleForTesting + static final ConcreteType AUGMENTATION = typeForClass(Augmentation.class); + @VisibleForTesting + static final ConcreteType IDENTIFIABLE = typeForClass(Identifiable.class); + @VisibleForTesting + static final ConcreteType IDENTIFIER = typeForClass(Identifier.class); + @VisibleForTesting + static final ConcreteType INSTANCE_IDENTIFIER = typeForClass(InstanceIdentifier.class); + private static final ConcreteType ACTION = typeForClass(Action.class); private static final ConcreteType CHILD_OF = typeForClass(ChildOf.class); private static final ConcreteType CHOICE_IN = typeForClass(ChoiceIn.class); + private static final ConcreteType INSTANCE_NOTIFICATION = typeForClass(InstanceNotification.class); + private static final ConcreteType KEYED_INSTANCE_IDENTIFIER = typeForClass(KeyedInstanceIdentifier.class); + private static final ConcreteType KEYED_LIST_ACTION = typeForClass(KeyedListAction.class); + private static final ConcreteType KEYED_LIST_NOTIFICATION = typeForClass(KeyedListNotification.class); + private static final ConcreteType OPAQUE_OBJECT = typeForClass(OpaqueObject.class); private static final ConcreteType RPC_RESULT = typeForClass(RpcResult.class); private BindingTypes() { @@ -73,7 +95,46 @@ public final class BindingTypes { * @throws NullPointerException if any argument is is null */ public static ParameterizedType action(final Type parent, final Type input, final Type output) { - return parameterizedTypeFor(ACTION, parent, input, output); + return parameterizedTypeFor(ACTION, instanceIdentifier(parent), input, output); + } + + /** + * Type specializing {@link KeyedListAction} for a particular type. + * + * @param parent Type of parent defining the action + * @param keyType Type of parent's key + * @param input Type input type + * @param output Type output type + * @return A parameterized type corresponding to {@code KeyedListAction} + * @throws NullPointerException if any argument is is null + */ + public static ParameterizedType keyedListAction(final Type parent, final Type keyType, final Type input, + final Type output) { + return parameterizedTypeFor(KEYED_LIST_ACTION, keyType, parent, input, output); + } + + /** + * Type specializing {@link InstanceNotification} for a particular type. + * + * @param parent Type of parent defining the notification + * @return A parameterized type corresponding to {@code InstanceNotification} + * @throws NullPointerException if {@code parent} is is null + */ + public static ParameterizedType instanceNotification(final Type concreteType, final Type parent) { + return parameterizedTypeFor(INSTANCE_NOTIFICATION, concreteType, parent); + } + + /** + * Type specializing {@link InstanceNotification} for a particular type. + * + * @param parent Type of parent defining the notification + * @param keyType Type of parent's key + * @return A parameterized type corresponding to {@code KeyedInstanceNotification} + * @throws NullPointerException if any argument is is null + */ + public static ParameterizedType keyedListNotification(final Type concreteType, final Type parent, + final Type keyType) { + return parameterizedTypeFor(KEYED_LIST_NOTIFICATION, concreteType, parent, keyType); } /** @@ -83,7 +144,7 @@ public final class BindingTypes { * @return A parameterized type corresponding to {@code Augmentable} * @throws NullPointerException if {@code type} is null */ - public static ParameterizedType augmentable(final Type type) { + public static @NonNull ParameterizedType augmentable(final Type type) { return parameterizedTypeFor(AUGMENTABLE, type); } @@ -142,6 +203,29 @@ public final class BindingTypes { return parameterizedTypeFor(INSTANCE_IDENTIFIER, type); } + /** + * Type specializing {@link KeyedInstanceIdentifier} for a particular type. + * + * @param type Type for which to specialize + * @param keyType Type of key + * @return A parameterized type corresponding to {@code KeyedInstanceIdentifier} + * @throws NullPointerException if any argument is is null + */ + public static ParameterizedType keyedInstanceIdentifier(final Type type, final Type keyType) { + return parameterizedTypeFor(KEYED_INSTANCE_IDENTIFIER, type, keyType); + } + + /** + * Type specializing {@link OpaqueObject} for a particular type. + * + * @param type Type for which to specialize + * @return A parameterized type corresponding to {@code OpaqueObject} + * @throws NullPointerException if {@code type} is null + */ + public static ParameterizedType opaqueObject(final Type type) { + return parameterizedTypeFor(OPAQUE_OBJECT, type); + } + /** * Type specializing {@link RpcResult} for a particular type. *