Interface IMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>

  • Type Parameters:
    INTERFACETYPE - The interface type of the elements handled by the DAO
    All Superinterfaces:
    com.helger.commons.lang.IHasSize
    All Known Implementing Classes:
    AbstractMapBasedWALDAO

    @ThreadSafe
    public interface IMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>
    extends com.helger.commons.lang.IHasSize
    Read-only base interface for the MAP based DAO
    Author:
    Philip Helger
    • Method Detail

      • getNone

        @Nonnull
        @ReturnsMutableCopy
        <T> com.helger.commons.collection.impl.ICommonsList<T> getNone()
        Type Parameters:
        T - Response type.
        Returns:
        An empty collection of the suitable implementation type.
        Since:
        9.4.5 in the interface
      • getAll

        @Nonnull
        @ReturnsMutableCopy
        com.helger.commons.collection.impl.ICommonsList<? extends INTERFACETYPE> getAll()
        Returns:
        A list of all contained items. Never null.
      • getAll

        @Nonnull
        @ReturnsMutableCopy
        com.helger.commons.collection.impl.ICommonsList<? extends INTERFACETYPE> getAll​(@Nullable
                                                                                        Predicate<? super INTERFACETYPE> aFilter)
        Parameters:
        aFilter - Filter to be applied. May be null.
        Returns:
        A list of all contained items matching the filter. Never null.
      • findAll

        void findAll​(@Nullable
                     Predicate<? super INTERFACETYPE> aFilter,
                     @Nonnull
                     Consumer<? super INTERFACETYPE> aConsumer)
        Find all items matching the filter and invoke the consumer on all matching entries.
        Parameters:
        aFilter - The filter to be applied. May be null.
        aConsumer - The consumer to be invoked for all matches. May not be null.
      • getAllMapped

        @Nonnull
        @ReturnsMutableCopy
        <RETTYPE> com.helger.commons.collection.impl.ICommonsList<RETTYPE> getAllMapped​(@Nullable
                                                                                        Predicate<? super INTERFACETYPE> aFilter,
                                                                                        @Nonnull
                                                                                        Function<? super INTERFACETYPE,​? extends RETTYPE> aMapper)
        Get all contained items matching the provided filter and map them to something else.
        Type Parameters:
        RETTYPE - Return type to which is mapped
        Parameters:
        aFilter - The filter to be applied. May be null.
        aMapper - The mapper to be invoked. May not be null.
        Returns:
        The list all matching and mapped elements. Never null.
      • findAllMapped

        <RETTYPE> void findAllMapped​(@Nullable
                                     Predicate<? super INTERFACETYPE> aFilter,
                                     @Nonnull
                                     Function<? super INTERFACETYPE,​? extends RETTYPE> aMapper,
                                     @Nonnull
                                     Consumer<? super RETTYPE> aConsumer)
        Find all contained items that match the filter, map them to a different type and invoke the consumer on all mapped items.
        Type Parameters:
        RETTYPE - Return type to which is mapped
        Parameters:
        aFilter - The filter to be applied. May be null.
        aMapper - The mapper to be invoked. May not be null.
        aConsumer - The consumer to be invoked for all matches. May not be null.
      • containsAny

        boolean containsAny​(@Nullable
                            Predicate<? super INTERFACETYPE> aFilter)
        Parameters:
        aFilter - The filter to be applied. May be null.
        Returns:
        true if at least one item matches the filter
      • containsNone

        boolean containsNone​(@Nullable
                             Predicate<? super INTERFACETYPE> aFilter)
        Parameters:
        aFilter - The filter to be applied. May be null.
        Returns:
        true if no item matches the filter
      • containsOnly

        boolean containsOnly​(@Nullable
                             Predicate<? super INTERFACETYPE> aFilter)
        Parameters:
        aFilter - The filter to be applied. May be null.
        Returns:
        true if all items match the filter
      • containsWithID

        boolean containsWithID​(@Nullable
                               String sID)
        Parameters:
        sID - The ID to be checked. May be null.
        Returns:
        true if an item with the provided ID is contained.
      • forEach

        void forEach​(@Nullable
                     BiConsumer<? super String,​? super INTERFACETYPE> aConsumer)
        Iterate each entry
        Parameters:
        aConsumer - Consumer to use. May be null.
        Since:
        9.4.5 in the interface
      • forEachKey

        void forEachKey​(@Nullable
                        Consumer<? super String> aConsumer)
        Iterate each key
        Parameters:
        aConsumer - Consumer to use. May be null.
        Since:
        9.4.5 in the interface
      • forEachKey

        void forEachKey​(@Nullable
                        Predicate<? super String> aFilter,
                        @Nullable
                        Consumer<? super String> aConsumer)
        Iterate each key
        Parameters:
        aFilter - Optional filter to limit the entries for which the consumer is called. May be null.
        aConsumer - Consumer to use. May be null.
        Since:
        9.4.5 in the interface
      • forEachValue

        void forEachValue​(@Nullable
                          Consumer<? super INTERFACETYPE> aConsumer)
        Iterate each value
        Parameters:
        aConsumer - Consumer to use. May be null.
        Since:
        9.4.5 in the interface
      • forEachValue

        void forEachValue​(@Nullable
                          Predicate<? super INTERFACETYPE> aFilter,
                          @Nullable
                          Consumer<? super INTERFACETYPE> aConsumer)
        Iterate each value
        Parameters:
        aFilter - Optional filter to limit the entries for which the consumer is called. May be null.
        aConsumer - Consumer to use. May be null.
        Since:
        9.4.5 in the interface
      • containsAllIDs

        boolean containsAllIDs​(@Nullable
                               Iterable<String> aIDs)
        Check if all IDs are contained
        Parameters:
        aIDs - IDs to check
        Returns:
        true if all IDs are contained
        Since:
        9.4.5 in the interface
      • getAllIDs

        @Nonnull
        @ReturnsMutableCopy
        com.helger.commons.collection.impl.ICommonsSet<String> getAllIDs()
        Returns:
        A set with the IDs of all contained items. Never null but maybe empty.
      • getCount

        @Nonnegative
        int getCount​(@Nullable
                     Predicate<? super INTERFACETYPE> aFilter)
        Parameters:
        aFilter - The filter to be applied. May be null.
        Returns:
        The number of items matching the provided filter. Always ≥ 0.