ff93bac36bf1d90a33298e1816e7b91cfd381083
[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.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.mdsal.common.api.ReadFailedException;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16
17 /**
18  * Read-like operations supported by {@link ReadTransaction} and {@link ReadWriteTransaction}. This interface defines
19  * the operations without a tie-in with lifecycle management.
20  */
21 public interface ReadOperations {
22     /**
23      * Reads data from the provided logical data store located at the provided path.
24      *
25      * <p>
26      * If the target is a subtree, then the whole subtree is read (and will be accessible from the returned data
27      * object).
28      *
29      * @param store Logical data store from which read should occur.
30      * @param path Path which uniquely identifies subtree which client want to read
31      * @return a FluentFuture containing the result of the read. The Future blocks until the commit operation is
32      *         complete. Once complete:
33      *         <ul>
34      *         <li>If the data at the supplied path exists, the Future returns an Optional object containing the data.
35      *         </li>
36      *         <li>If the data at the supplied path does not exist, the Future returns Optional.empty().</li>
37      *         <li>If the read of the data fails, the Future will fail with a {@link ReadFailedException} or
38      *         an exception derived from ReadFailedException.</li>
39      *         </ul>
40      */
41     <T extends DataObject> FluentFuture<Optional<T>> read(LogicalDatastoreType store, InstanceIdentifier<T> path);
42 }