blob: 9de9780d47eb477d196307c3c1f012b46d742140 [file] [log] [blame]
Madan Jampaniad5b8c72016-09-12 15:05:01 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.store.service;
18
19import java.util.Iterator;
20
21import javax.annotation.concurrent.NotThreadSafe;
22
23/**
24 * A {@code DocumentTree} node.
25 *
26 * @param <V> value type
27 */
28@NotThreadSafe
29public interface DocumentTreeNode<V> {
30
31 /**
32 * Returns the path to this node in a {@code DocumentTree}.
33 *
34 * @return absolute path
35 */
36 DocumentPath path();
37
38 /**
39 * Returns the value of this node.
40 *
41 * @return node value (and version)
42 */
43 Versioned<V> value();
44
45 /**
46 * Returns the children of this node.
47 *
48 * @return iterator for this node's children
49 */
50 Iterator<DocumentTreeNode<V>> children();
51
52 /**
53 * Returns the child node of this node with the specified relative path name.
54 *
55 * @param relativePath relative path name for the child node.
56 * @return child node; this method returns {@code null} if no such child exists
57 */
58 DocumentTreeNode<V> child(String relativePath);
59
60 /**
61 * Returns if this node has one or more children.
62 * @return {@code true} if yes, {@code false} otherwise
63 */
64 default boolean hasChildren() {
65 return children().hasNext();
66 }
67}