Expose completion future from WriteOperations
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMDataTreeWriteOperations.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies. 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 edu.umd.cs.findbugs.annotations.CheckReturnValue;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
15 import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18
19 public interface DOMDataTreeWriteOperations {
20     /**
21      * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
22      * subtree will be replaced by the specified data.
23      *
24      * <p>
25      * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
26      * put, consider using {@link #merge} instead.
27      *
28      * @param store the logical data store which should be modified
29      * @param path the data object path
30      * @param data the data object to be written to the specified path
31      * @throws IllegalArgumentException if {@code store} is not supported
32      * @throws IllegalStateException if the transaction has already been submitted
33      * @throws NullPointerException if any argument is {@code null}
34      * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
35      */
36     void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data);
37
38     /**
39      * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
40      * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
41      *
42      * <p>
43      * If you require an explicit replace operation, use {@link #put} instead.
44      *
45      * @param store the logical data store which should be modified
46      * @param path the data object path
47      * @param data the data object to be merged to the specified path
48      * @throws IllegalArgumentException if {@code store} is not supported
49      * @throws IllegalStateException if the transaction has already been submitted
50      * @throws NullPointerException if any argument is {@code null}
51      * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
52      */
53     void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data);
54
55     /**
56      * Removes a piece of data from specified path. This operation does not fail if the specified path does not exist.
57      *
58      * @param store Logical data store which should be modified
59      * @param path Data object path
60      * @throws IllegalArgumentException if {@code store} is not supported
61      * @throws IllegalStateException if the transaction was committed or canceled.
62      * @throws NullPointerException if any argument is {@code null}
63      * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
64      */
65     void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
66
67     /**
68      * Return a {@link FluentFuture} which completes.
69      *
70      * @return A future which completes when the requested operations complete.
71      */
72     @Beta
73     @CheckReturnValue
74     @NonNull FluentFuture<?> completionFuture();
75 }