KEYTYPE - The type of the key elements for the tree.DATATYPE - The type of the elements contained in the treeITEMTYPE - tree item type@NotThreadSafe public class BasicTreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>> extends BasicTreeWithID<KEYTYPE,DATATYPE,ITEMTYPE> implements ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE>
| Constructor and Description |
|---|
BasicTreeWithGlobalUniqueID(ITreeItemWithUniqueIDFactory<KEYTYPE,DATATYPE,ITEMTYPE> aFactory) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsItemWithID(KEYTYPE aDataID)
Check if a tree item corresponding to the given ID is present.
|
boolean |
equals(Object o) |
List<? extends ITEMTYPE> |
getAllChildren(ITEMTYPE aItem)
Get the children of the passed object.
|
Collection<DATATYPE> |
getAllItemDatas() |
Collection<ITEMTYPE> |
getAllItems() |
int |
getChildCount(ITEMTYPE aItem) |
ITEMTYPE |
getChildWithID(ITEMTYPE aCurrentItem,
KEYTYPE aDataID)
Retrieve the objects with the passed ID or
null if no such
object. |
protected ITreeItemWithUniqueIDFactory<KEYTYPE,DATATYPE,ITEMTYPE> |
getFactory() |
int |
getItemCount() |
DATATYPE |
getItemDataWithID(KEYTYPE aDataID)
Get the data of the tree item that corresponds to the given ID.
|
ITEMTYPE |
getItemWithID(KEYTYPE aDataID)
Get the
ITreeItemWithID that corresponds to the given ID. |
boolean |
hasChildren(ITEMTYPE aItem)
Check if an item has children.
|
int |
hashCode() |
boolean |
isItemSameOrDescendant(KEYTYPE aParentItemID,
KEYTYPE aChildItemID)
Check if one item is equal or a child of the other item.
|
EChange |
removeItemWithID(KEYTYPE aDataID)
Remove the item with the specified ID
|
String |
toString() |
getAllChildren, getChildCount, getRootItem, hasChildrenclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetRootItemgetAllChildren, getChildCount, hasChildrenpublic BasicTreeWithGlobalUniqueID(@Nonnull ITreeItemWithUniqueIDFactory<KEYTYPE,DATATYPE,ITEMTYPE> aFactory)
@Nonnull protected final ITreeItemWithUniqueIDFactory<KEYTYPE,DATATYPE,ITEMTYPE> getFactory()
public final boolean containsItemWithID(@Nullable KEYTYPE aDataID)
ITreeWithGlobalUniqueIDcontainsItemWithID in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aDataID - The ID of the tree item to search.true if such an item is present@Nullable public final ITEMTYPE getItemWithID(@Nullable KEYTYPE aDataID)
ITreeWithGlobalUniqueIDITreeItemWithID that corresponds to the given ID.getItemWithID in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aDataID - The ID of the tree item to search.null if no such tree item exists.@Nullable public final DATATYPE getItemDataWithID(@Nullable KEYTYPE aDataID)
ITreeWithGlobalUniqueIDgetItemDataWithID in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aDataID - The ID of the tree item to search.null if no such tree item exists.@Nullable public final ITEMTYPE getChildWithID(@Nullable ITEMTYPE aCurrentItem, @Nullable KEYTYPE aDataID)
IChildrenProviderWithIDnull if no such
object.getChildWithID in interface IChildrenProviderWithID<KEYTYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aCurrentItem - The object to determine the children of. No null or
non- null constraint possible.aDataID - the ID of the object in question. No null or non-
null constraint possible.null@Nonnegative public final int getItemCount()
getItemCount in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>@Nonnull @ReturnsMutableCopy public final Collection<ITEMTYPE> getAllItems()
getAllItems in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>null collection of all items.@Nonnull @ReturnsMutableCopy public final Collection<DATATYPE> getAllItemDatas()
getAllItemDatas in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>null collection of all item datas.@Nonnull public final EChange removeItemWithID(@Nullable KEYTYPE aDataID)
ITreeWithGlobalUniqueIDremoveItemWithID in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aDataID - The ID of the item to be removedEChange.CHANGED if the item was removed,
EChange.UNCHANGED otherwise. Never null.public final boolean isItemSameOrDescendant(@Nullable KEYTYPE aParentItemID, @Nullable KEYTYPE aChildItemID)
ITreeWithGlobalUniqueIDisItemSameOrDescendant in interface ITreeWithGlobalUniqueID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aParentItemID - The parent item ID to a validate.aChildItemID - The item ID to check whether it is a child of the passed parent
folder.true if the child item is the same or a child of the
parent item, false if one of the IDs could not be
resolved or they are not in a parent-child-relationship.public boolean hasChildren(@Nullable ITEMTYPE aItem)
IChildrenProviderhasChildren in interface IChildrenProvider<ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aItem - The object to determine the children of. No null or
non- null constraint possible.true if this item has children, false
otherwise.@Nonnegative public int getChildCount(@Nullable ITEMTYPE aItem)
getChildCount in interface IChildrenProvider<ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aItem - The object to determine the children count of. No null
or non- null constraint possible.@Nullable public List<? extends ITEMTYPE> getAllChildren(@Nullable ITEMTYPE aItem)
IChildrenProvidergetAllChildren in interface IChildrenProvider<ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>aItem - The object to determine the children of. No null or
non-null constraint possible.null if there are no children.
If null is passed, the resolver is expected to return
any possible top level (root) elements. This method may NOT return
null if the call to IChildrenProvider.hasChildren(Object) with
the same object returned true.public boolean equals(Object o)
equals in class BasicTreeWithID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>public int hashCode()
hashCode in class BasicTreeWithID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>public String toString()
toString in class BasicTreeWithID<KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>Copyright © 2014–2016 Philip Helger. All rights reserved.