Expose completion future from WriteOperations
[mdsal.git] / binding / mdsal-binding-util / src / main / java / org / opendaylight / mdsal / binding / util / TypedWriteTransaction.java
1 /*
2  * Copyright © 2018 Red Hat, Inc. and others.
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.util;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.FluentFuture;
12 import edu.umd.cs.findbugs.annotations.CheckReturnValue;
13 import org.opendaylight.mdsal.binding.api.Transaction;
14 import org.opendaylight.mdsal.binding.api.WriteOperations;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 /**
20  * Write transaction which is specific to a single logical datastore (configuration or operational). Designed for use
21  * with {@link ManagedNewTransactionRunner} (it doesn’t support explicit cancel or commit operations).
22  *
23  * @param <D> The logical datastore handled by the transaction.
24  * @see WriteOperations
25  */
26 public interface TypedWriteTransaction<D extends Datastore> extends Transaction {
27     /**
28      * Writes an object to the given path.
29      *
30      * @see WriteOperations#put(LogicalDatastoreType, InstanceIdentifier, DataObject)
31      *
32      * @param path The path to write to.
33      * @param data The object to write.
34      * @param <T> The type of the provided object.
35      */
36     <T extends DataObject> void put(InstanceIdentifier<T> path, T data);
37
38     /**
39      * Writes an object to the given path, creating significant parents, like presence containers and list entries,
40      * if needed.
41      *
42      * @see WriteOperations#mergeParentStructurePut(LogicalDatastoreType, InstanceIdentifier, DataObject)
43      *
44      * @param path The path to write to.
45      * @param data The object to write.
46      * @param <T> The type of the provided object.
47      */
48     // TODO: can we come up with a better name?
49     @Beta
50     <T extends DataObject> void mergeParentStructurePut(InstanceIdentifier<T> path, T data);
51
52     /**
53      * Merges an object with the data already present at the given path.
54      *
55      * @see WriteOperations#merge(LogicalDatastoreType, InstanceIdentifier, DataObject)
56      *
57      * @param path The path to write to.
58      * @param data The object to merge.
59      * @param <T> The type of the provided object.
60      */
61     <T extends DataObject> void merge(InstanceIdentifier<T> path, T data);
62
63     /**
64      * Merges an object with the data already present at the given path, creating missing parents if requested.
65      *
66      * @see WriteOperations#merge(LogicalDatastoreType, InstanceIdentifier, DataObject)
67      *
68      * @param path The path to write to.
69      * @param data The object to merge.
70      * @param <T> The type of the provided object.
71      */
72     // TODO: can we come up with a better name?
73     @Beta
74     <T extends DataObject> void mergeParentStructureMerge(InstanceIdentifier<T> path, T data);
75
76     /**
77      * Deletes the object present at the given path.
78      *
79      * @see WriteOperations#delete(LogicalDatastoreType, InstanceIdentifier)
80      *
81      * @param path The path to delete.
82      */
83     void delete(InstanceIdentifier<?> path);
84
85     /**
86      * Return a {@link FluentFuture} which completes.
87      *
88      * @return A future which completes when the requested operations complete.
89      */
90     @Beta
91     @CheckReturnValue
92     FluentFuture<?> completionFuture();
93 }