Add QueryOperations
[mdsal.git] / binding / mdsal-binding-util / src / main / java / org / opendaylight / mdsal / binding / util / TypedReadTransaction.java
index 25cb823fd3e2fff4fb965ee9d98d5094215d75f3..c6556c6ec7777a681c5fda7aa7d806c0802aa266 100644 (file)
@@ -9,9 +9,13 @@ package org.opendaylight.mdsal.binding.util;
 
 import com.google.common.util.concurrent.FluentFuture;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.api.ReadTransaction;
 import org.opendaylight.mdsal.binding.api.Transaction;
+import org.opendaylight.mdsal.binding.api.query.QueryExpression;
+import org.opendaylight.mdsal.binding.api.query.QueryResult;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -44,4 +48,21 @@ public interface TypedReadTransaction<D extends Datastore> extends Transaction {
      * @return A future providing access to the result of the check, when it’s available, or any error encountered.
      */
     FluentFuture<Boolean> exists(InstanceIdentifier<?> path);
+
+    /**
+     * Executes a {@link QueryExpression}.
+     *
+     * @param query Query to execute
+     * @return a FluentFuture containing the result of the query. The Future blocks until the operation is complete.
+     *         Once complete:
+     *         <ul>
+     *           <li>The Future returns the result of the query</li>
+     *           <li>If the query execution fails, the Future will fail with a {@link ReadFailedException} or
+     *               an exception derived from ReadFailedException.
+     *            </li>
+     *         </ul>
+     * @throws NullPointerException if any of the arguments is null
+     * @throws IllegalArgumentException if the query is not supported
+     */
+    <T extends @NonNull DataObject> FluentFuture<QueryResult<T>> execute(QueryExpression<T> query);
 }