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 java.util.Optional;
12 import org.eclipse.jdt.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 operations relative to that
19 * position, as well as moving the position up or down the tree. Implementations are expected to be NOT thread-safe.
22 public interface DataTreeSnapshotCursor extends AutoCloseable {
24 * Move the cursor to the specified child of the current position.
26 * @param child Child identifier
27 * @throws BackendFailedException when an implementation-specific error occurs
28 * while servicing the request.
29 * @throws IllegalArgumentException when specified identifier does not identify
30 * a valid child, or if that child is not an
31 * instance of {@link NormalizedNodeContainer}.
33 void enter(@NonNull PathArgument child);
36 * Move the cursor to the specified child of the current position. This is
37 * the equivalent of multiple invocations of {@link #enter(PathArgument)},
38 * except the operation is performed all at once.
40 * @param path Nested child identifier
41 * @throws BackendFailedException when an implementation-specific error occurs
42 * while servicing the request.
43 * @throws IllegalArgumentException when specified path does not identify
44 * a valid child, or if that child is not an
45 * instance of {@link NormalizedNodeContainer}.
47 void enter(@NonNull PathArgument... path);
50 * Move the cursor to the specified child of the current position. This is
51 * equivalent to {@link #enter(PathArgument...)}, except it takes an {@link Iterable}
54 * @param path Nested child identifier
55 * @throws BackendFailedException when an implementation-specific error occurs
56 * while servicing the request.
57 * @throws IllegalArgumentException when specified path does not identify
58 * a valid child, or if that child is not an
59 * instance of {@link NormalizedNodeContainer}.
61 void enter(@NonNull Iterable<PathArgument> path);
64 * Move the cursor up to the parent of current position. This is equivalent of
65 * invoking <code>exit(1)</code>.
67 * @throws IllegalStateException when exiting would violate containment, typically
68 * by attempting to exit more levels than previously
74 * Move the cursor up by specified amounts of steps from the current position.
75 * This is equivalent of invoking {@link #exit()} multiple times, except the
76 * operation is performed atomically.
78 * @param depth number of steps to exit
79 * @throws IllegalArgumentException when depth is negative.
80 * @throws IllegalStateException when exiting would violate containment, typically
81 * by attempting to exit more levels than previously
87 * Read a particular node from the snapshot.
89 * @param child Child identifier
90 * @return Optional result encapsulating the presence and value of the node
91 * @throws BackendFailedException when implementation-specific error occurs while
92 * servicing the request.
93 * @throws IllegalArgumentException when specified path does not identify a valid child.
95 Optional<NormalizedNode<?, ?>> readNode(@NonNull PathArgument child);
98 * Close this cursor. Attempting any further operations on the cursor will lead
99 * to undefined behavior.