Interface IHasChildren<CHILDTYPE>

  • Type Parameters:
    CHILDTYPE - The type of the children.
    All Known Subinterfaces:
    IHasChildrenRecursive<CHILDTYPE>, IHasChildrenSorted<CHILDTYPE>

    public interface IHasChildren<CHILDTYPE>
    A simple interface, indicating that an item has direct children.
    Author:
    Philip Helger
    • Method Detail

      • hasChildren

        default boolean hasChildren()
        Returns:
        true if this item has direct children, false otherwise.
      • hasNoChildren

        default boolean hasNoChildren()
        Returns:
        true if this item has no direct children, false otherwise.
      • getChildCount

        @Nonnegative
        int getChildCount()
        Returns:
        The number of contained direct children. Always ≥ 0.
      • forAllChildren

        default void forAllChildren​(@Nonnull
                                    Consumer<? super CHILDTYPE> aConsumer)
        Perform something on all children (if any).
        Note: use this only for reading. Writing operations will potentially cause concurrent modification exceptions!
        Parameters:
        aConsumer - The consumer to be invoked. May not be null.
      • forAllChildrenBreakable

        @Nonnull
        default EContinue forAllChildrenBreakable​(@Nonnull
                                                  Function<? super CHILDTYPE,​EContinue> aConsumer)
        Perform something on all children (if any).
        Note: use this only for reading. Writing operations will potentially cause concurrent modification exceptions!
        Parameters:
        aConsumer - The breakable consumer to be invoked. May not be null.
        Returns:
        EContinue.BREAK if iteration was stopped, EContinue.CONTINUE otherwise.
      • forAllChildren

        default void forAllChildren​(@Nonnull
                                    Predicate<? super CHILDTYPE> aFilter,
                                    @Nonnull
                                    Consumer<? super CHILDTYPE> aConsumer)
        Iterate all direct children (if at least one is present) and invoke the provided consumer if the passed predicate is fulfilled.
        Note: use this only for reading. Writing operations will potentially cause concurrent modification exceptions!
        Parameters:
        aFilter - The filter that is applied to all children. May not be null.
        aConsumer - The consumer to be invoked for all children matching the filter. May not be null.
      • forAllChildrenMapped

        default <DSTTYPE> void forAllChildrenMapped​(@Nonnull
                                                    Predicate<? super CHILDTYPE> aFilter,
                                                    @Nonnull
                                                    Function<? super CHILDTYPE,​? extends DSTTYPE> aMapper,
                                                    @Nonnull
                                                    Consumer<? super DSTTYPE> aConsumer)
        Iterate all direct children (if at least one is present) and invoked the provided consumer if the passed predicate is fulfilled.
        Note: use this only for reading. Writing operations will potentially cause concurrent modification exceptions!
        Type Parameters:
        DSTTYPE - The destination data type.
        Parameters:
        aFilter - The filter that is applied to all children. May not be null.
        aMapper - The mapping function from child type to the target type. May not be null.
        aConsumer - The consumer to be invoked for all target types matching the filter. May not be null.