Migrate mdsal-binding-api to JDT annotations
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / CursorAwareWriteTransaction.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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
9 package org.opendaylight.mdsal.binding.api;
10
11 import com.google.common.util.concurrent.FluentFuture;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.common.api.CommitInfo;
14 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16
17 /**
18  * Write transaction that provides cursor's with write access to the data tree.
19  */
20 public interface CursorAwareWriteTransaction extends DataTreeCursorProvider {
21     /**
22      * Create a {@link DataTreeWriteCursor} anchored at the specified path.
23      * There can only be one cursor open at a time.
24      *
25      * <p>
26      * @param path Path at which the cursor is to be anchored
27      * @return write cursor at the desired location.
28      * @throws IllegalStateException when there's an open cursor, or this transaction is closed already.
29      */
30     @Override
31     <T extends DataObject> DataTreeWriteCursor createCursor(DataTreeIdentifier<T> path);
32
33     /**
34      * Cancels the transaction.
35      *
36      * <p>
37      * A transaction can only be cancelled if it has not yet been committed.
38      *
39      * <p>
40      * Invoking cancel() on failed or already canceled will have no effect, and transaction is
41      * considered cancelled.
42      *
43      * <p>
44      * Invoking cancel() on finished transaction (future returned by {@link #commit()} already
45      * successfully completed) will always fail (return false).
46      *
47      * @return <tt>false</tt> if the task could not be cancelled, typically because it has already
48      *         completed normally; <tt>true</tt> otherwise
49      *
50      */
51     boolean cancel();
52
53     /**
54      * Commits this transaction to be asynchronously applied to update the logical data tree. The
55      * returned CheckedFuture conveys the result of applying the data changes.
56      *
57      * <p>
58      * <b>Note:</b> It is strongly recommended to process the FluentFuture result in an
59      * asynchronous manner rather than using the blocking get() method.
60      *
61      * <p>
62      * This call logically seals the transaction, which prevents the client from further changing
63      * data tree using this transaction's cursor. Any subsequent calls to
64      * <code>createCursorCursor(DOMDataTreeIdentifier</code>
65      * or any of the cursor's methods will fail with {@link IllegalStateException}.
66      *
67      * <p>
68      * The transaction is marked as submitted and enqueued into the shard back-end for
69      * processing.
70      *
71      * @return a FluentFuture containing the result of the commit information. The Future blocks until the commit
72      *         operation is complete. A successful commit returns nothing. On failure, the Future will fail with a
73      *         {@link TransactionCommitFailedException} or an exception derived from TransactionCommitFailedException.
74      */
75     FluentFuture<? extends @NonNull CommitInfo> commit();
76 }