2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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.yangtools.yang.data.api.schema.tree;
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Optional;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
18 * A cursor holding a logical position within a {@link DataTreeSnapshot}. It allows
19 * operations relative to that position, as well as moving the position up or down
23 public interface DataTreeSnapshotCursor extends AutoCloseable {
25 * Move the cursor to the specified child of the current position.
27 * @param child Child identifier
28 * @throws BackendFailedException when implementation-specific errors occurs
29 * while servicing the request.
30 * @throws IllegalArgumentException when specified identifier does not identify
31 * a valid child, or if that child is not an
32 * instance of {@link NormalizedNodeContainer}.
34 void enter(@Nonnull PathArgument child);
37 * Move the cursor to the specified child of the current position. This is
38 * the equivalent of multiple invocations of {@link #enter(PathArgument)},
39 * except the operation is performed atomically.
41 * @param path Nested child identifier
42 * @throws BackendFailedException when implementation-specific errors occurs
43 * while servicing the request.
44 * @throws IllegalArgumentException when specified path does not identify
45 * a valid child, or if that child is not an
46 * instance of {@link NormalizedNodeContainer}.
48 void enter(@Nonnull PathArgument... path);
51 * Move the cursor to the specified child of the current position. This is
52 * equivalent to {@link #enter(PathArgument...)}, except it takes an {@link Iterable}
55 * @param path Nested child identifier
56 * @throws BackendFailedException when implementation-specific errors occurs
57 * while servicing the request.
58 * @throws IllegalArgumentException when specified path does not identify
59 * a valid child, or if that child is not an
60 * instance of {@link NormalizedNodeContainer}.
62 void enter(@Nonnull Iterable<PathArgument> path);
65 * Move the cursor up to the parent of current position. This is equivalent of
66 * invoking <code>exit(1)</code>.
68 * @throws IllegalStateException when exiting would violate containment, typically
69 * by attempting to exit more levels than previously
75 * Move the cursor up by specified amounts of steps from the current position.
76 * This is equivalent of invoking {@link #exit()} multiple times, except the
77 * operation is performed atomically.
79 * @param depth number of steps to exit
80 * @throws IllegalArgumentException when depth is negative.
81 * @throws IllegalStateException when exiting would violate containment, typically
82 * by attempting to exit more levels than previously
88 * Read a particular node from the snapshot.
90 * @param child Child identifier
91 * @return Optional result encapsulating the presence and value of the node
92 * @throws BackendFailedException when implementation-specific error occurs while
93 * servicing the request.
94 * @throws IllegalArgumentException when specified path does not identify a valid child.
96 Optional<NormalizedNode<?, ?>> readNode(@Nonnull PathArgument child);
99 * Close this cursor. Attempting any further operations on the cursor will lead
100 * to undefined behavior.