DATATYPE - tree item value typeITEMTYPE - tree item implementation type@NotThreadSafe public class BasicTreeItem<DATATYPE,ITEMTYPE extends ITreeItem<DATATYPE,ITEMTYPE>> extends Object implements ITreeItem<DATATYPE,ITEMTYPE>
ITreeItem interface| Constructor and Description |
|---|
BasicTreeItem(ITEMTYPE aParent)
Constructor for normal elements.
|
BasicTreeItem(ITreeItemFactory<DATATYPE,ITEMTYPE> aFactory)
Constructor for root object.
|
| Modifier and Type | Method and Description |
|---|---|
com.helger.commons.state.ESuccess |
changeParent(ITEMTYPE aNewParent)
Change the parent node of this node to another node (subordination).
|
ITEMTYPE |
createChildItem(DATATYPE aData)
Add a child item to this item.
|
boolean |
equals(Object o) |
ITEMTYPE |
findFirstChild(Predicate<? super ITEMTYPE> aFilter) |
<DSTTYPE> DSTTYPE |
findFirstChildMapped(Predicate<? super ITEMTYPE> aFilter,
Function<? super ITEMTYPE,? extends DSTTYPE> aMapper) |
void |
forAllChildren(Consumer<? super ITEMTYPE> aConsumer) |
void |
forAllChildren(Predicate<? super ITEMTYPE> aFilter,
Consumer<? super ITEMTYPE> aConsumer) |
com.helger.commons.state.EContinue |
forAllChildrenBreakable(Function<? super ITEMTYPE,com.helger.commons.state.EContinue> aConsumer) |
<DSTTYPE> void |
forAllChildrenMapped(Predicate<? super ITEMTYPE> aFilter,
Function<? super ITEMTYPE,? extends DSTTYPE> aMapper,
Consumer<? super DSTTYPE> aConsumer) |
com.helger.commons.collection.impl.ICommonsList<DATATYPE> |
getAllChildDatas()
Get the data values of all contained children.
|
com.helger.commons.collection.impl.ICommonsList<ITEMTYPE> |
getAllChildren() |
ITEMTYPE |
getChildAtIndex(int nIndex) |
int |
getChildCount() |
com.helger.commons.collection.impl.ICommonsIterable<ITEMTYPE> |
getChildren() |
DATATYPE |
getData() |
ITreeItemFactory<DATATYPE,ITEMTYPE> |
getFactory() |
ITEMTYPE |
getFirstChild() |
ITEMTYPE |
getLastChild() |
int |
getLevel() |
ITEMTYPE |
getParent() |
DATATYPE |
getParentData() |
boolean |
hasChildren() |
int |
hashCode() |
com.helger.commons.state.EChange |
internalAddChild(ITEMTYPE aChild)
Add an existing child to this tree item.
|
boolean |
isRootItem() |
boolean |
isSameOrChildOf(ITEMTYPE aParent)
Check if this item is the same or a child of the passed item.
|
protected boolean |
isValidData(DATATYPE aData)
This method is called to validate a data object.
|
com.helger.commons.state.EChange |
removeChild(ITEMTYPE aChild)
Remove the passed node as a child node from this node.
|
void |
reorderChildItems(Comparator<? super ITEMTYPE> aComparator)
Reorder the child items based on the item itself.
|
void |
setData(DATATYPE aData)
Change the data associated with this node.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic BasicTreeItem(@Nonnull ITreeItemFactory<DATATYPE,ITEMTYPE> aFactory)
aFactory - The factory to use for creating tree items. May not be
null.@Nonnull public final ITreeItemFactory<DATATYPE,ITEMTYPE> getFactory()
@OverrideOnDemand protected boolean isValidData(DATATYPE aData)
aData - The value to validate.true if the ID is valid, false otherwise.public final void setData(@Nullable DATATYPE aData)
IBasicTreeItempublic final boolean isRootItem()
isRootItem in interface IBasicTreeItem<DATATYPE,ITEMTYPE extends ITreeItem<DATATYPE,ITEMTYPE>>true if this is the internal root item without a
parent, false if this is a public item.@Nullable public final DATATYPE getParentData()
getParentData in interface IBasicTreeItem<DATATYPE,ITEMTYPE extends ITreeItem<DATATYPE,ITEMTYPE>>null.
This is like a shortcut for getParent().getData() with
implicit null handling.@Nonnegative public final int getLevel()
@Nonnull public final ITEMTYPE createChildItem(@Nullable DATATYPE aData)
public final boolean hasChildren()
@Nullable @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<ITEMTYPE> getAllChildren()
@Nullable public final com.helger.commons.collection.impl.ICommonsIterable<ITEMTYPE> getChildren()
@Nonnull public final com.helger.commons.state.EContinue forAllChildrenBreakable(@Nonnull Function<? super ITEMTYPE,com.helger.commons.state.EContinue> aConsumer)
public final void forAllChildren(@Nonnull Predicate<? super ITEMTYPE> aFilter, @Nonnull Consumer<? super ITEMTYPE> aConsumer)
public final <DSTTYPE> void forAllChildrenMapped(@Nonnull Predicate<? super ITEMTYPE> aFilter, @Nonnull Function<? super ITEMTYPE,? extends DSTTYPE> aMapper, @Nonnull Consumer<? super DSTTYPE> aConsumer)
@Nullable @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<DATATYPE> getAllChildDatas()
IBasicTreeItemgetAllChildDatas in interface IBasicTreeItem<DATATYPE,ITEMTYPE extends ITreeItem<DATATYPE,ITEMTYPE>>null if this item does not have children. Use
IHasChildren.hasChildren() to check for the existence.@Nullable public final ITEMTYPE getChildAtIndex(@Nonnegative int nIndex)
@Nonnegative public final int getChildCount()
@Nullable public final ITEMTYPE findFirstChild(@Nonnull Predicate<? super ITEMTYPE> aFilter)
@Nullable public final <DSTTYPE> DSTTYPE findFirstChildMapped(@Nonnull Predicate<? super ITEMTYPE> aFilter, @Nonnull Function<? super ITEMTYPE,? extends DSTTYPE> aMapper)
public final boolean isSameOrChildOf(@Nonnull ITEMTYPE aParent)
IBasicTreeItemisSameOrChildOf in interface IBasicTreeItem<DATATYPE,ITEMTYPE extends ITreeItem<DATATYPE,ITEMTYPE>>aParent - The parent item to check whether this is a child of it. May not be
null.true if this is the same or a child of
aParent.@Nonnull public final com.helger.commons.state.ESuccess changeParent(@Nonnull ITEMTYPE aNewParent)
IBasicTreeItemchangeParent in interface IBasicTreeItem<DATATYPE,ITEMTYPE extends ITreeItem<DATATYPE,ITEMTYPE>>aNewParent - The new parent to use. May not be null. To make it a
root item, pass the owning tree's root item.ESuccess@Nonnull public final com.helger.commons.state.EChange internalAddChild(@Nonnull ITEMTYPE aChild)
ITreeItem@Nonnull public final com.helger.commons.state.EChange removeChild(@Nonnull ITEMTYPE aChild)
ITreeItempublic final void reorderChildItems(@Nonnull Comparator<? super ITEMTYPE> aComparator)
ITreeItemCopyright © 2014–2021 Philip Helger. All rights reserved.