Module gen.tree
Package io.github.astrapi69.gen.tree.api
Interface ITreeNode<V,T extends ITreeNode<V,T>>
-
- Type Parameters:
V
- the generic type of the valueT
- the generic type of the concrete tree node
- All Superinterfaces:
io.github.astrapi69.design.pattern.visitor.Acceptable<io.github.astrapi69.design.pattern.visitor.Visitor<T>>
,io.github.astrapi69.tree.api.ITree<V,T>
,java.io.Serializable
- All Known Subinterfaces:
IBaseTreeNode<V,K,T>
- All Known Implementing Classes:
BaseTreeNode
,TreeNode
public interface ITreeNode<V,T extends ITreeNode<V,T>> extends io.github.astrapi69.tree.api.ITree<V,T>, io.github.astrapi69.design.pattern.visitor.Acceptable<io.github.astrapi69.design.pattern.visitor.Visitor<T>>
The InterfaceITreeNode
holds the children in aCollection
object
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default void
accept(@NonNull io.github.astrapi69.design.pattern.visitor.Visitor<T> visitor)
default void
addChild(T child)
Adds the given childdefault void
addChildren(@NonNull java.util.Collection<T> children)
Adds all the given childrendefault void
clearAll()
Removes all the descendantsdefault void
clearChildren()
Removes all the childrendefault boolean
contains(T treeNode)
Checks if the givenITreeNode
object is a descendant of this tree nodedefault boolean
containsAll(@NonNull java.util.Collection<T> treeNodes)
Checks if the givenCollection
object ofITreeNode
objects are descendants of this tree nodedefault java.util.Collection<T>
findAllByValue(V value)
Find allITreeNode
objects that have the same value as the given valuedefault T
findByValue(V value)
Find allITreeNode
objects that have the same value as the given valuedefault java.util.Collection<T>
getAllSiblings()
Returns all siblings of this node in the parent's children list.default int
getChildCount()
Gets the child count.default int
getLevel()
Returns the distance from the root to this node.default T
getNextSibling()
Returns the next sibling of this node in the parent's children list.default T
getPreviousSibling()
Returns the previous sibling of this node in the parent's children list.default T
getRoot()
Gets the root objectdefault boolean
hasChildren()
Checks for children.default boolean
hasParent()
Checks for parentdefault boolean
isNode()
Checks if is node.default boolean
isRoot()
default void
removeChild(T child)
Removes the child.default void
removeChildren()
Removes all the childrendefault void
removeChildren(@NonNull java.util.Collection<T> children)
Removes all the given childrendefault java.util.List<T>
toList()
Traverse this node and adds all descendant with this included in to aList
objectdefault java.util.Collection<T>
traverse()
Traverse this node and adds all descendant with this included in to aCollection
object
-
-
-
Method Detail
-
addChild
default void addChild(T child)
Adds the given child
-
addChildren
default void addChildren(@NonNull @NonNull java.util.Collection<T> children)
Adds all the given children
-
getAllSiblings
default java.util.Collection<T> getAllSiblings()
Returns all siblings of this node in the parent's children list. Returns null if this node is the root.
-
getPreviousSibling
default T getPreviousSibling()
Returns the previous sibling of this node in the parent's children list. Returns null if this node is the root or is the parent's first child.
-
getNextSibling
default T getNextSibling()
Returns the next sibling of this node in the parent's children list. Returns null if this node is the root or is the parent's last child.
-
getChildCount
default int getChildCount()
Gets the child count.
-
getLevel
default int getLevel()
Returns the distance from the root to this node. Returns 0 if this node is the root.
-
getRoot
default T getRoot()
Gets the root object
-
hasChildren
default boolean hasChildren()
Checks for children.
-
hasParent
default boolean hasParent()
Checks for parent
-
isNode
default boolean isNode()
Checks if is node.
-
isRoot
default boolean isRoot()
-
removeChild
default void removeChild(T child)
Removes the child.
-
clearChildren
default void clearChildren()
Removes all the children
-
clearAll
default void clearAll()
Removes all the descendants
-
removeChildren
default void removeChildren()
Removes all the children
-
removeChildren
default void removeChildren(@NonNull @NonNull java.util.Collection<T> children)
Removes all the given children
-
accept
default void accept(@NonNull @NonNull io.github.astrapi69.design.pattern.visitor.Visitor<T> visitor)
- Specified by:
accept
in interfaceio.github.astrapi69.design.pattern.visitor.Acceptable<V>
-
findAllByValue
default java.util.Collection<T> findAllByValue(V value)
Find allITreeNode
objects that have the same value as the given value
-
findByValue
default T findByValue(@NonNull V value)
Find allITreeNode
objects that have the same value as the given value
-
contains
default boolean contains(T treeNode)
Checks if the givenITreeNode
object is a descendant of this tree node
-
containsAll
default boolean containsAll(@NonNull @NonNull java.util.Collection<T> treeNodes)
Checks if the givenCollection
object ofITreeNode
objects are descendants of this tree node
-
toList
default java.util.List<T> toList()
Traverse this node and adds all descendant with this included in to aList
object
-
traverse
default java.util.Collection<T> traverse()
Traverse this node and adds all descendant with this included in to aCollection
object
-
-