From f343810d045cd28301fb95cffbd1ba8fa7db76c1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 18 Jun 2018 22:21:56 +0200 Subject: [PATCH] Add Action and RpcOutput interfaces This patch adds the binding interface prototype for actions. Codegen will attach to specializations of this interface for concrete generated types. JIRA: MDSAL-300 Change-Id: I2fc97df50033b0d2d8f96b8281a82999a6b62869 Signed-off-by: Robert Varga --- .../binding/model/util/BindingTypes.java | 30 ++++++++++++++++ .../yangtools/yang/binding/Action.java | 35 +++++++++++++++++++ .../yangtools/yang/binding/RpcInput.java | 4 +++ .../yangtools/yang/binding/RpcOutput.java | 21 +++++++++++ 4 files changed, 90 insertions(+) create mode 100644 binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Action.java create mode 100644 binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcOutput.java 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 69c2dc424e..9b0c66ba44 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 @@ -14,6 +14,7 @@ import org.opendaylight.mdsal.binding.model.api.ConcreteType; import org.opendaylight.mdsal.binding.model.api.JavaTypeName; import org.opendaylight.mdsal.binding.model.api.ParameterizedType; import org.opendaylight.mdsal.binding.model.api.Type; +import org.opendaylight.yangtools.yang.binding.Action; import org.opendaylight.yangtools.yang.binding.Augmentable; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.BaseIdentity; @@ -27,6 +28,8 @@ import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.binding.NotificationListener; +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.annotations.RoutingContext; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -44,11 +47,14 @@ public final class BindingTypes { 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 RPC_INPUT = typeForClass(RpcInput.class); + public static final ConcreteType RPC_OUTPUT = typeForClass(RpcOutput.class); public static final ConcreteType RPC_SERVICE = typeForClass(RpcService.class); // This is an annotation, we are current just referencing the type public static final JavaTypeName ROUTING_CONTEXT = JavaTypeName.create(RoutingContext.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 RPC_RESULT = typeForClass(RpcResult.class); @@ -57,6 +63,19 @@ public final class BindingTypes { } + /** + * Type specializing {@link Action} for a particular type. + * + * @param parent Type of parent defining the action + * @param input Type input type + * @param output Type output type + * @return A parameterized type corresponding to {@code Action} + * @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); + } + /** * Specialize {@link Augmentable} for a particular type. * @@ -112,6 +131,17 @@ public final class BindingTypes { return parameterizedTypeFor(IDENTIFIABLE, type); } + /** + * Type specializing {@link InstanceIdentifier} for a particular type. + * + * @param type Type for which to specialize + * @return A parameterized type corresponding to {@code InstanceIdentifier} + * @throws NullPointerException if {@code type} is null + */ + public static ParameterizedType instanceIdentifier(final Type type) { + return parameterizedTypeFor(INSTANCE_IDENTIFIER, type); + } + /** * Type specializing {@link RpcResult} for a particular type. * diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Action.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Action.java new file mode 100644 index 0000000000..861101d54a --- /dev/null +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Action.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.yang.binding; + +import com.google.common.annotations.Beta; +import com.google.common.util.concurrent.FluentFuture; +import javax.annotation.CheckReturnValue; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.opendaylight.yangtools.yang.common.RpcResult; + +/** + * Interface extended by all interfaces generated for a YANG {@code action}. + * + * @author Robert Varga + */ +@Beta +@FunctionalInterface +@NonNullByDefault +public interface Action

{ + /** + * Invoke the action. + * + * @param path Invocation path + * @param input Input argument + * @return Future result of invocation + * @throws NullPointerException if any of the arguments are null + */ + @CheckReturnValue + FluentFuture> invoke(InstanceIdentifier

path, I input); +} diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java index 11b95bdea5..a79663d53f 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcInput.java @@ -7,6 +7,10 @@ */ package org.opendaylight.yangtools.yang.binding; +/** + * Marker interface for all interfaces generated for {@code input} statement within an {@code action} or an {@code rpc} + * statement. + */ public interface RpcInput extends DataContainer { } diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcOutput.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcOutput.java new file mode 100644 index 0000000000..502807e81c --- /dev/null +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/RpcOutput.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.yang.binding; + +import com.google.common.annotations.Beta; + +/** + * Marker interface for all interfaces generated for {@code output} statement within an {@code action} or an {@code rpc} + * statement. + * + * @author Robert Varga + */ +@Beta +public interface RpcOutput extends DataContainer { + +} -- 2.36.6