0664838588cb7b354a8d6f7de173d90d61399f86
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMDataTreeReadCursor.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.dom.api;
9
10 import com.google.common.base.Optional;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.mdsal.common.api.ReadFailedException;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16
17 public interface DOMDataTreeReadCursor extends DOMDataTreeCursor {
18
19     /**
20      * Read a particular node from the snapshot.
21      *
22      * @param child Child identifier
23      * @return Optional result encapsulating the presence and value of the node
24      * @throws IllegalArgumentException when specified path does not identify a valid child.
25      */
26     CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readNode(@Nonnull PathArgument child);
27
28     /**
29      * Checks if data is available in the logical data store located at provided path.
30      * <p>
31      *
32      * Note: a successful result from this method makes no guarantee that a subsequent call to
33      * {@link #readNode(PathArgument)} will succeed. It is possible that the data resides in a data store on a remote
34      * node and, if that node goes down or a network failure occurs, a subsequent read would fail.
35      * Another scenario is if the data is deleted in between the calls to <code>exists</code> and
36      * <code>readNode</code>
37      *
38      * @param child Child identifier
39      * @return a CheckFuture containing the result of the check.
40      *         <ul>
41      *         <li>If the data at the supplied path exists, the Future returns a Boolean whose value
42      *         is true, false otherwise</li> <li>If checking for the data fails, the Future will
43      *         fail with a {@link ReadFailedException} or an exception derived from
44      *         ReadFailedException.</li>
45      *         </ul>
46      */
47     CheckedFuture<Boolean, ReadFailedException> exists(@Nonnull PathArgument child);
48 }