2 * Copyright © 2018 Red Hat, Inc. and others.
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
8 package org.opendaylight.mdsal.binding.util;
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.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 * Read transaction which is specific to a single logical datastore (configuration or operational). Designed for use
24 * with {@link ManagedNewTransactionRunner} (it doesn’t support explicit cancel or commit operations).
26 * @see ReadTransaction
28 * @param <D> The logical datastore handled by the transaction.
30 public interface TypedReadTransaction<D extends Datastore> extends Transaction {
32 * Reads an object from the given path.
34 * @see ReadTransaction#read(LogicalDatastoreType, InstanceIdentifier)
36 * @param path The path to read from.
37 * @param <T> The type of the expected object.
38 * @return A future providing access to the result of the read, when it’s available, or any error encountered.
40 <T extends DataObject> FluentFuture<Optional<T>> read(InstanceIdentifier<T> path);
43 * Determines if an object exists at the given path.
45 * @see ReadTransaction#exists(LogicalDatastoreType, InstanceIdentifier)
47 * @param path The path to read from.
48 * @return A future providing access to the result of the check, when it’s available, or any error encountered.
50 FluentFuture<Boolean> exists(InstanceIdentifier<?> path);
53 * Executes a {@link QueryExpression}.
55 * @param query Query to execute
56 * @return a FluentFuture containing the result of the query. The Future blocks until the operation is complete.
59 * <li>The Future returns the result of the query</li>
60 * <li>If the query execution fails, the Future will fail with a {@link ReadFailedException} or
61 * an exception derived from ReadFailedException.
64 * @throws NullPointerException if any of the arguments is null
65 * @throws IllegalArgumentException if the query is not supported
67 <T extends @NonNull DataObject> FluentFuture<QueryResult<T>> execute(QueryExpression<T> query);