Package com.helger.tree.withid
Interface ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>
-
- Type Parameters:
KEYTYPE- The type of the ID.DATATYPE- The type of the value.ITEMTYPE- The implementation type.
- All Superinterfaces:
IBasicTreeItem<DATATYPE,ITEMTYPE>,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.id.IHasID<KEYTYPE>,com.helger.commons.hierarchy.IHasParent<ITEMTYPE>
- All Known Subinterfaces:
IFolderTreeItem<KEYTYPE,DATATYPE,COLLTYPE,ITEMTYPE>
- All Known Implementing Classes:
BasicFolderTreeItem,BasicTreeItemWithID,DefaultFolderTreeItem,DefaultTreeItemWithID
public interface ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>> extends IBasicTreeItem<DATATYPE,ITEMTYPE>, com.helger.commons.id.IHasID<KEYTYPE>
Represents a basic tree item with an ID. Never use this class directly but provide a sub interface that specifies the generic T parameter.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontainsChildItemWithDataID(KEYTYPE aDataID)Check if a direct child item with the given ID is presentITEMTYPEcreateChildItem(KEYTYPE aDataID, DATATYPE aData)Add a direct child item to this item.ITEMTYPEcreateChildItem(KEYTYPE aDataID, DATATYPE aData, boolean bAllowOverwrite)Add a direct child item to this item.com.helger.commons.collection.impl.ICommonsSet<KEYTYPE>getAllChildDataIDs()ITEMTYPEgetChildItemOfDataID(KEYTYPE aDataID)Find the direct child item with the given IDITreeItemWithIDFactory<KEYTYPE,DATATYPE,ITEMTYPE>getFactory()KEYTYPEgetID()KEYTYPEgetParentID()com.helger.commons.state.EChangeinternalAddChild(KEYTYPE aDataID, ITEMTYPE aChild, boolean bAllowOverwrite)Add an existing direct child to this tree item.com.helger.commons.state.EChangeremoveAllChildren()Remove all children from this node.com.helger.commons.state.EChangeremoveChild(KEYTYPE aDataID)Remove the passed node as a direct child node from this node.voidreorderChildrenByItems(Comparator<? super ITEMTYPE> aComparator)Reorder the child items based on the item itself.-
Methods inherited from interface com.helger.tree.IBasicTreeItem
changeParent, getAllChildDatas, getData, getLevel, getParentData, isRootItem, isSameOrChildOf, setData
-
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
-
getFactory
@Nonnull ITreeItemWithIDFactory<KEYTYPE,DATATYPE,ITEMTYPE> getFactory()
- Returns:
- The factory used to create instances of this interface.
-
getID
KEYTYPE getID()
- Specified by:
getIDin interfacecom.helger.commons.id.IHasID<KEYTYPE>- Returns:
- The data ID of this item. May be
nulldepending on the validator.
-
getParentID
KEYTYPE getParentID()
- Returns:
- The data ID of the parent item. May be
nullif no parent is present or depending on the validator.
-
getAllChildDataIDs
@Nullable @ReturnsMutableCopy com.helger.commons.collection.impl.ICommonsSet<KEYTYPE> getAllChildDataIDs()
- Returns:
- A set with the data IDs of all children. If this tree item does not
have children,
nullif returned.
-
containsChildItemWithDataID
boolean containsChildItemWithDataID(@Nullable KEYTYPE aDataID)
Check if a direct child item with the given ID is present- Parameters:
aDataID- The ID to search. May benull.- Returns:
trueif this item has a child with the given ID,falseotherwise
-
getChildItemOfDataID
@Nullable ITEMTYPE getChildItemOfDataID(@Nullable KEYTYPE aDataID)
Find the direct child item with the given ID- Parameters:
aDataID- The ID to search. May benull.- Returns:
nullif this item has no child with the given ID. The item otherwise.
-
internalAddChild
@Nonnull com.helger.commons.state.EChange internalAddChild(@Nonnull KEYTYPE aDataID, @Nonnull ITEMTYPE aChild, boolean bAllowOverwrite)
Add an existing direct child to this tree item. Use only internally!- Parameters:
aDataID- The data ID to use. May not benull.aChild- The child to be added. May not benull.bAllowOverwrite- iftrueexisting elements are overwritten.- Returns:
EChange
-
createChildItem
ITEMTYPE createChildItem(@Nullable KEYTYPE aDataID, @Nullable DATATYPE aData)
Add a direct child item to this item. If another item with the same ID is already contained, the item is automatically overwritten.- Parameters:
aDataID- ID of the item to generate. May benullin rare circumstances.aData- The data associated with this item.- Returns:
- the created tree item. May be null in certain implementations
-
createChildItem
@Nullable ITEMTYPE createChildItem(KEYTYPE aDataID, DATATYPE aData, boolean bAllowOverwrite)
Add a direct child item to this item.- Parameters:
aDataID- ID of the item to generate. May not benull.aData- The data associated with this item.bAllowOverwrite- Iftruea potential existing child item with the same ID is overwritten.- Returns:
- the created tree item or
nullif the data ID is already in use and bAllowOverwrite isfalse
-
removeChild
@Nonnull com.helger.commons.state.EChange removeChild(@Nullable KEYTYPE aDataID)
Remove the passed node as a direct child node from this node.- Parameters:
aDataID- The ID of the element to be removed. May not benull.- Returns:
EChange
-
removeAllChildren
@Nonnull com.helger.commons.state.EChange removeAllChildren()
Remove all children from this node.- Returns:
EChange
-
reorderChildrenByItems
void reorderChildrenByItems(@Nonnull Comparator<? super ITEMTYPE> aComparator)
Reorder the child items based on the item itself.- Parameters:
aComparator- The comparator use. May not benull.
-
-