Package com.helger.tree
Interface IBasicTreeItem<DATATYPE,ITEMTYPE extends IBasicTreeItem<DATATYPE,ITEMTYPE>>
-
- Type Parameters:
DATATYPE- Data type of the items.ITEMTYPE- tree item type
- All Superinterfaces:
com.helger.commons.traits.IGenericImplTrait<ITEMTYPE>,com.helger.commons.hierarchy.IHasChildren<ITEMTYPE>,com.helger.commons.hierarchy.IHasChildrenRecursive<ITEMTYPE>,com.helger.commons.hierarchy.IHasChildrenSorted<ITEMTYPE>,com.helger.commons.hierarchy.IHasParent<ITEMTYPE>
- All Known Subinterfaces:
IFolderTreeItem<KEYTYPE,DATATYPE,COLLTYPE,ITEMTYPE>,ITreeItem<DATATYPE,ITEMTYPE>,ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>
- All Known Implementing Classes:
BasicFolderTreeItem,BasicTreeItem,BasicTreeItemWithID,DefaultFolderTreeItem,DefaultTreeItem,DefaultTreeItemWithID
public interface IBasicTreeItem<DATATYPE,ITEMTYPE extends IBasicTreeItem<DATATYPE,ITEMTYPE>> extends com.helger.commons.hierarchy.IHasParent<ITEMTYPE>, com.helger.commons.hierarchy.IHasChildrenSorted<ITEMTYPE>, com.helger.commons.hierarchy.IHasChildrenRecursive<ITEMTYPE>, com.helger.commons.traits.IGenericImplTrait<ITEMTYPE>Base interface both for normal tree items and tree items with ID.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.helger.commons.state.ESuccesschangeParent(ITEMTYPE aNewParent)Change the parent node of this node to another node (subordination).com.helger.commons.collection.impl.ICommonsList<DATATYPE>getAllChildDatas()Get the data values of all contained children.DATATYPEgetData()intgetLevel()DATATYPEgetParentData()booleanisRootItem()booleanisSameOrChildOf(ITEMTYPE aParent)Check if this item is the same or a child of the passed item.voidsetData(DATATYPE aData)Change the data associated with this node.-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildren
forAllChildren, forAllChildren, forAllChildrenBreakable, forAllChildrenMapped, getChildCount, getChildren, hasChildren, hasNoChildren
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildrenRecursive
forAllChildrenRecursive, forAllChildrenRecursive
-
-
-
-
Method Detail
-
getParentData
@Nullable DATATYPE getParentData()
- Returns:
- the data associated with the parent node. May be
null. This is like a shortcut forgetParent().getData()with implicitnullhandling.
-
getLevel
@Nonnegative int getLevel()
- Returns:
- The nesting level of this node. The root node has level 0. A child of the root item has level 1 etc.
- Since:
- 5.5.0
-
getAllChildDatas
@Nullable com.helger.commons.collection.impl.ICommonsList<DATATYPE> getAllChildDatas()
Get the data values of all contained children.- Returns:
nullif this item does not have children. UseIHasChildren.hasChildren()to check for the existence.
-
setData
void setData(@Nullable DATATYPE aData)
Change the data associated with this node.- Parameters:
aData- The data associated with this node. May benull.- Throws:
IllegalArgumentException- If the data is not valid (depending on any custom validator).
-
isRootItem
boolean isRootItem()
- Returns:
trueif this is the internal root item without a parent,falseif this is a public item.
-
isSameOrChildOf
boolean isSameOrChildOf(@Nonnull ITEMTYPE aParent)
Check if this item is the same or a child of the passed item. This is not limited to direct children but to children on all levels.- Parameters:
aParent- The parent item to check whether this is a child of it. May not benull.- Returns:
trueifthisis the same or a child of aParent.
-
changeParent
@Nonnull com.helger.commons.state.ESuccess changeParent(@Nonnull ITEMTYPE aNewParent)
Change the parent node of this node to another node (subordination).- Parameters:
aNewParent- The new parent to use. May not benull. To make it a root item, pass the owning tree's root item.- Returns:
ESuccess
-
-