/
EntityTree.java
93 lines (83 loc) · 2.96 KB
/
EntityTree.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright (c) 2019 Otávio Santana and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Otavio Santana
*/
package org.eclipse.jnosql.artemis.graph;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Stream;
/**
* A wrapper of {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree} to manipulate entities classes.
*/
public interface EntityTree {
/**
* A wrapper {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree#getLeafObjects}
*
* @param <T> the entity type
* @return the leaf {@link Stream} of this Tree
*/
<T> Stream<T> getLeaf();
/**
* A wrapper {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree#keySet()}
*
* @param <T> the entity type
* @return the leaf {@link Stream} of this Tree
*/
<T> Stream<T> getRoots();
/**
* An {@link Entry} where the key is the ID and the value is Entity
*
* @param <K> the key type
* @param <V> the entity type
* @return the {@link Stream} of {@link Entry} of the root of the tree
*/
<K, V> Stream<Entry<K, V>> getRootsIds();
/**
* Returns tree from the root id
*
* @param id the id
* @param <T> the id type
* @return the entity if it is a leaf it will return {@link Optional#isPresent()}
*/
<T> Optional<EntityTree> getTreeFromRoot(T id);
/**
* Returns a {@link Stream} of {@link EntityTree} it is a wrapper of
* {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree#getLeafTrees}
*
* @return a stream of {@link EntityTree}
*/
Stream<EntityTree> getLeafTrees();
/**
* Returns a {@link Stream} of {@link EntityTree} it is a wrapper of
* {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree#getTreesAtDepth(int)}
*
* @param depth the depth
* @return a {@link Stream} of {@link EntityTree}
*/
Stream<EntityTree> getTreesAtDepth(int depth);
/**
* Returns a {@link Stream} of {@link EntityTree} it is a wrapper of
* {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree#getObjectsAtDepth(int)}
*
* @param depth the depth
* @param <T> the entity type
* @return a {@link Stream} of entities
*/
<T> Stream<T> getLeafsAtDepth(int depth);
/**
* It is a wrapper of {@link org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree#isLeaf()}
*
* @return true if is leaf or not
*/
boolean isLeaf();
}