Fix action invocation and registration
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / ReadOperations.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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 package org.opendaylight.mdsal.binding.api;
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.common.api.LogicalDatastoreType;
14 import org.opendaylight.mdsal.common.api.ReadFailedException;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17
18 /**
19  * Read-like operations supported by {@link ReadTransaction} and {@link ReadWriteTransaction}. This interface defines
20  * the operations without a tie-in with lifecycle management.
21  */
22 public interface ReadOperations {
23     /**
24      * Reads data from the provided logical data store located at the provided path.
25      *
26      * <p>
27      * If the target is a subtree, then the whole subtree is read (and will be accessible from the returned data
28      * object).
29      *
30      * @param store Logical data store from which read should occur.
31      * @param path Path which uniquely identifies subtree which client want to read
32      * @return a FluentFuture containing the result of the read. The Future blocks until the operation is complete. Once
33      *         complete:
34      *         <ul>
35      *         <li>If the data at the supplied path exists, the Future returns an Optional object containing the data.
36      *         </li>
37      *         <li>If the data at the supplied path does not exist, the Future returns Optional.empty().</li>
38      *         <li>If the read of the data fails, the Future will fail with a {@link ReadFailedException} or
39      *         an exception derived from ReadFailedException.</li>
40      *         </ul>
41      * @throws NullPointerException if any of the arguments is null
42      * @throws IllegalArgumentException if the path is {@link InstanceIdentifier#isWildcarded()}
43      */
44     <T extends DataObject> @NonNull FluentFuture<Optional<T>> read(@NonNull LogicalDatastoreType store,
45             @NonNull InstanceIdentifier<T> path);
46
47     /**
48      * Determines if data data exists in the provided logical data store located at the provided path.
49      *
50      * <p>
51      * Default implementation just delegates to {@link #read(LogicalDatastoreType, InstanceIdentifier)}. Implementations
52      * are recommended to override with a more efficient implementation.
53      *
54      * @param store Logical data store from which read should occur.
55      * @param path Path which uniquely identifies subtree which client want to read
56      * @return a FluentFuture containing the result of the check. The Future blocks until the operation is complete.
57      *         Once complete:
58      *         <ul>
59      *         <li>If the data at the supplied path exists, the Future returns {@link Boolean#TRUE}.
60      *         </li>
61      *         <li>If the data at the supplied path does not exist, the Future returns {@link Boolean#FALSE}.</li>
62      *         <li>If the check fails, the Future will fail with a {@link ReadFailedException} or an exception derived
63      *             from ReadFailedException.</li>
64      *         </ul>
65      * @throws NullPointerException if any of the arguments is null
66      * @throws IllegalArgumentException if the path is {@link InstanceIdentifier#isWildcarded()} and the implementation
67      *                                  does not support evaluating wildcards.
68      */
69     @NonNull FluentFuture<Boolean> exists(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<?> path);
70 }