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.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;
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).
27 * @see ReadTransaction
29 * @param <D> The logical datastore handled by the transaction.
31 public interface TypedReadTransaction<D extends Datastore> extends Transaction {
33 * Reads an object from the given path.
35 * @see ReadTransaction#read(LogicalDatastoreType, DataObjectIdentifier)
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.
41 <T extends DataObject> FluentFuture<Optional<T>> read(DataObjectIdentifier<T> path);
44 * Determines if an object exists at the given path.
46 * @see ReadTransaction#exists(LogicalDatastoreType, DataObjectIdentifier)
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.
51 FluentFuture<Boolean> exists(DataObjectIdentifier<?> path);
54 * Executes a {@link QueryExpression}.
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.
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.
66 * @throws NullPointerException if any of the arguments is null
67 * @throws IllegalArgumentException if the query is not supported
69 <T extends @NonNull DataObject> FluentFuture<QueryResult<T>> execute(QueryExpression<T> query);