Class DefaultIterableTreeNode<O>
- java.lang.Object
-
- org.nuiton.jaxx.runtime.swing.tree.DefaultIterableTreeNode<O>
-
- All Implemented Interfaces:
Iterable<IterableTreeNode<?>>,TreeNode,IterableTreeNode<O>
public class DefaultIterableTreeNode<O> extends Object implements IterableTreeNode<O>
Default implementation of aIterableTreeNode.Created by tchemit on 05/01/2018.
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuiton.jaxx.runtime.swing.tree.IterableTreeNode
IterableTreeNode.BreadthFirstIterator, IterableTreeNode.PostorderIterator, IterableTreeNode.PreorderIterator
-
-
Field Summary
-
Fields inherited from interface org.nuiton.jaxx.runtime.swing.tree.IterableTreeNode
EMPTY_ITERATOR, STREAM_CHARACTERISTICS
-
-
Constructor Summary
Constructors Constructor Description DefaultIterableTreeNode(O userObject, boolean allowsChildren)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(IterableTreeNode<?> newChild)Enumerationchildren()booleangetAllowsChildren()IterableTreeNode<?>getChildAt(int childIndex)intgetChildCount()intgetIndex(TreeNode node)IterableTreeNode<?>getParent()IterableTreeNode<?>getRoot()OgetUserObject()voidinsertChild(IterableTreeNode<?> newChild, int position)booleanisEmpty()booleanisLeaf()booleanisNodeAncestor(IterableTreeNode anotherNode)Returns true ifanotherNodeis an ancestor of this node -- if it is this node, this node's parent, or an ancestor of this node's parent.booleanisRoot()Iterator<IterableTreeNode<?>>iterator()voidremoveChild(int index)Remove child at givenindex.voidremoveChild(IterableTreeNode<?> child)Remove given givenchild.voidremoveChildren()Removes all of this node's children, setting their parents to null.voidremoveChildren(List<IterableTreeNode<?>> children)Remove given children.voidsetAllowsChildren(boolean allowsChildren)voidsetParent(IterableTreeNode<?> parent)voidsetUserObject(O userObject)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.nuiton.jaxx.runtime.swing.tree.IterableTreeNode
breadthFirstIterator, postorderIterator, preorderIterator, stream
-
-
-
-
Constructor Detail
-
DefaultIterableTreeNode
public DefaultIterableTreeNode(O userObject, boolean allowsChildren)
-
-
Method Detail
-
getChildAt
public IterableTreeNode<?> getChildAt(int childIndex)
- Specified by:
getChildAtin interfaceTreeNode
-
getChildCount
public final int getChildCount()
- Specified by:
getChildCountin interfaceTreeNode
-
isRoot
public final boolean isRoot()
- Specified by:
isRootin interfaceIterableTreeNode<O>
-
getRoot
public IterableTreeNode<?> getRoot()
- Specified by:
getRootin interfaceIterableTreeNode<O>
-
getParent
public IterableTreeNode<?> getParent()
- Specified by:
getParentin interfaceIterableTreeNode<O>- Specified by:
getParentin interfaceTreeNode
-
setParent
public final void setParent(IterableTreeNode<?> parent)
- Specified by:
setParentin interfaceIterableTreeNode<O>
-
getAllowsChildren
public final boolean getAllowsChildren()
- Specified by:
getAllowsChildrenin interfaceTreeNode
-
setAllowsChildren
public final void setAllowsChildren(boolean allowsChildren)
- Specified by:
setAllowsChildrenin interfaceIterableTreeNode<O>
-
children
public final Enumeration children()
-
iterator
public final Iterator<IterableTreeNode<?>> iterator()
-
isEmpty
public final boolean isEmpty()
- Specified by:
isEmptyin interfaceIterableTreeNode<O>
-
getUserObject
public final O getUserObject()
- Specified by:
getUserObjectin interfaceIterableTreeNode<O>
-
setUserObject
public final void setUserObject(O userObject)
- Specified by:
setUserObjectin interfaceIterableTreeNode<O>
-
addChild
public final void addChild(IterableTreeNode<?> newChild)
- Specified by:
addChildin interfaceIterableTreeNode<O>
-
insertChild
public final void insertChild(IterableTreeNode<?> newChild, int position)
- Specified by:
insertChildin interfaceIterableTreeNode<O>
-
removeChild
public final void removeChild(IterableTreeNode<?> child)
Description copied from interface:IterableTreeNodeRemove given givenchild.Will throw exception if given child is not a child of this node.
- Specified by:
removeChildin interfaceIterableTreeNode<O>- Parameters:
child- child to remove
-
removeChild
public final void removeChild(int index)
Description copied from interface:IterableTreeNodeRemove child at givenindex.Will throw exception if no child at index.
- Specified by:
removeChildin interfaceIterableTreeNode<O>- Parameters:
index- position of child to remove
-
removeChildren
public void removeChildren()
Description copied from interface:IterableTreeNodeRemoves all of this node's children, setting their parents to null. If this node has no children, this method does nothing.- Specified by:
removeChildrenin interfaceIterableTreeNode<O>
-
removeChildren
public void removeChildren(List<IterableTreeNode<?>> children)
Description copied from interface:IterableTreeNodeRemove given children. Acts as methodIterableTreeNode.removeChild(IterableTreeNode)for each element.- Specified by:
removeChildrenin interfaceIterableTreeNode<O>- Parameters:
children- children to remove
-
isNodeAncestor
public final boolean isNodeAncestor(IterableTreeNode anotherNode)
Returns true ifanotherNodeis an ancestor of this node -- if it is this node, this node's parent, or an ancestor of this node's parent. (Note that a node is considered an ancestor of itself.) IfanotherNodeis null, this method returns false. This operation is at worst O(h) where h is the distance from the root to this node.- Parameters:
anotherNode- node to test as an ancestor of this node- Returns:
- true if this node is a descendant of
anotherNode
-
-