Add forwarding transactions to binding v1
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMOperationImplementation.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.dom.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.FluentFuture;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17
18 /**
19  * Interface implemented by an individual operation implementation. This API allows for dispatch implementations, e.g.
20  * an individual object handling a multitude of operations.
21  *
22  * @author Robert Varga
23  */
24 @Beta
25 @NonNullByDefault
26 public interface DOMOperationImplementation {
27     /**
28      * An implementation of an {@code action}.
29      */
30     @FunctionalInterface
31     interface Action extends DOMOperationImplementation {
32         /**
33          * Initiate invocation of the action. Implementations of this method are expected to not block.
34          *
35          * @param type SchemaPath of the action to be invoked. This path refers to an effective action instantiated on
36          *             top of the conceptual {@link StoreTreeNode}.
37          * @param path {@link DOMDataTreeIdentifier} of parent data node which action attached to.
38          * @param input Input arguments
39          * @return A FluentFuture which completes with the result of invocation
40          * @throws NullPointerException if any of the arguments is null
41          */
42         FluentFuture<? extends DOMOperationResult> invokeAction(SchemaPath type, DOMDataTreeIdentifier path,
43                 ContainerNode input);
44     }
45
46     /**
47      * An implementation of an {@code rpc}.
48      */
49     @FunctionalInterface
50     interface Rpc extends DOMOperationImplementation {
51         /**
52          * Initiate invocation of the RPC. Implementations of this method are expected to not block.
53          *
54          * @param type QName of the RPC to be invoked
55          * @param input Input arguments
56          * @return A FluentFuture which completes with the result of invocation
57          * @throws NullPointerException if any of the arguments is null
58          */
59         FluentFuture<? extends DOMOperationResult> invokeRpc(QName type, ContainerNode input);
60     }
61
62     /**
63      * Return the relative invocation cost of this implementation. Default implementation returns 0.
64      *
65      * @return Non-negative cost of invoking this implementation.
66      */
67     default long invocationCost() {
68         return 0;
69     }
70 }