Create RemoteDeviceServices.{Actions,Rpcs}
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / api / RemoteDeviceServices.java
index ec784a0b825b941d3682a9d397eb7b0eb077ebd6..43be8d605ed1a3cc2feb74a96d4446b9c6625f03 100644 (file)
@@ -9,16 +9,59 @@ package org.opendaylight.netconf.sal.connect.api;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Actions;
+import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Rpcs;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 
 /**
  * Set of interfaces exposed by a {@link RemoteDevice}.
  */
-public record RemoteDeviceServices(@NonNull DOMRpcService rpcs, @Nullable DOMActionService actions) {
+public record RemoteDeviceServices(@NonNull Rpcs rpcs, @Nullable Actions actions) {
     public RemoteDeviceServices {
         requireNonNull(rpcs);
     }
+
+    /**
+     * Interface exposing NETCONF device RPC service. This interface is never implemented directly, but rather through
+     * its {@code non-sealed} specializations.
+     */
+    public sealed interface Rpcs extends NetconfRpcService permits Rpcs.Normalized, Rpcs.Schemaless {
+        /**
+         * NETCONF device RPCs operating just as any other {@link DOMRpcService}.
+         */
+        non-sealed interface Normalized extends Rpcs, DOMRpcService {
+            @Override
+            default ListenableFuture<? extends DOMRpcResult> invokeNetconf(final QName type,
+                    final ContainerNode input) {
+                return invokeRpc(type, input);
+            }
+        }
+
+        /**
+         * NETCONF device RPCs operating in terms of {@link SchemalessRpcService}.
+         */
+        non-sealed interface Schemaless extends Rpcs, SchemalessRpcService {
+            // Just an interface combination
+        }
+    }
+
+    /**
+     * Interface exposing NETCONF device Action service. This interface is never implemented directly, but rather
+     * through its {@code non-sealed} specializations.
+     */
+    public sealed interface Actions permits Actions.Normalized {
+        /**
+         * NETCONF device RPCs operating just as any other {@link DOMActionService}.
+         */
+        non-sealed interface Normalized extends Actions, DOMActionService {
+            // Just an interface combination
+        }
+    }
 }