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 Detail

      • getID

        KEYTYPE getID()
        Specified by:
        getID in interface com.helger.commons.id.IHasID<KEYTYPE>
        Returns:
        The data ID of this item. May be null depending on the validator.
      • getParentID

        KEYTYPE getParentID()
        Returns:
        The data ID of the parent item. May be null if 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, null if 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 be null.
        Returns:
        true if this item has a child with the given ID, false otherwise
      • getChildItemOfDataID

        @Nullable
        ITEMTYPE getChildItemOfDataID​(@Nullable
                                      KEYTYPE aDataID)
        Find the direct child item with the given ID
        Parameters:
        aDataID - The ID to search. May be null.
        Returns:
        null if 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 be null.
        aChild - The child to be added. May not be null.
        bAllowOverwrite - if true existing 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 be null in 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 be null.
        aData - The data associated with this item.
        bAllowOverwrite - If true a potential existing child item with the same ID is overwritten.
        Returns:
        the created tree item or null if the data ID is already in use and bAllowOverwrite is false
      • 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 be null.
        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 be null.