Bump versions to 14.0.3-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-util / src / main / java / org / opendaylight / mdsal / binding / util / TypedReadTransaction.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.util.concurrent.FluentFuture;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.binding.api.ReadTransaction;
14 import org.opendaylight.mdsal.binding.api.Transaction;
15 import org.opendaylight.mdsal.binding.api.query.QueryExpression;
16 import org.opendaylight.mdsal.binding.api.query.QueryResult;
17 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
18 import org.opendaylight.mdsal.common.api.ReadFailedException;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.datastores.rev180214.Datastore;
20 import org.opendaylight.yangtools.binding.DataObject;
21 import org.opendaylight.yangtools.binding.DataObjectIdentifier;
22
23 /**
24  * Read transaction which is specific to a single logical datastore (configuration or operational). Designed for use
25  * with {@link ManagedNewTransactionRunner} (it doesn’t support explicit cancel or commit operations).
26  *
27  * @see ReadTransaction
28  *
29  * @param <D> The logical datastore handled by the transaction.
30  */
31 public interface TypedReadTransaction<D extends Datastore> extends Transaction {
32     /**
33      * Reads an object from the given path.
34      *
35      * @see ReadTransaction#read(LogicalDatastoreType, DataObjectIdentifier)
36      *
37      * @param path The path to read from.
38      * @param <T> The type of the expected object.
39      * @return A future providing access to the result of the read, when it’s available, or any error encountered.
40      */
41     <T extends DataObject> FluentFuture<Optional<T>> read(DataObjectIdentifier<T> path);
42
43     /**
44      * Determines if an object exists at the given path.
45      *
46      * @see ReadTransaction#exists(LogicalDatastoreType, DataObjectIdentifier)
47      *
48      * @param path The path to read from.
49      * @return A future providing access to the result of the check, when it’s available, or any error encountered.
50      */
51     FluentFuture<Boolean> exists(DataObjectIdentifier<?> path);
52
53     /**
54      * Executes a {@link QueryExpression}.
55      *
56      * @param query Query to execute
57      * @param <T> The type of the expected object
58      * @return a FluentFuture containing the result of the query. The Future blocks until the operation is complete.
59      *         Once complete:
60      *         <ul>
61      *           <li>The Future returns the result of the query</li>
62      *           <li>If the query execution fails, the Future will fail with a {@link ReadFailedException} or
63      *               an exception derived from ReadFailedException.
64      *            </li>
65      *         </ul>
66      * @throws NullPointerException if any of the arguments is null
67      * @throws IllegalArgumentException if the query is not supported
68      */
69     <T extends @NonNull DataObject> FluentFuture<QueryResult<T>> execute(QueryExpression<T> query);
70 }