Class Filters


  • public final class Filters
    extends java.lang.Object

    Algorithm definitions for common operations using Filters.

    SPI Note:This class/these methods should be replaced with stream operations when JDK8 is required to build/run this plugin.

    Since:
    2.0
    See Also:
    Filter
    • Constructor Summary

      Constructors 
      Constructor Description
      Filters()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.io.FileFilter> adapt​(java.util.List<Filter<java.io.File>> toAdapt)
      Adapts the supplied List of Filter specifications to a List of FileFilters.
      static java.io.FileFilter adapt​(Filter<java.io.File> toAdapt)
      Adapts the Filter specification to the FileFilter interface, to enable immediate use for filtering File lists.
      static <T> void initialize​(org.apache.maven.plugin.logging.Log log, java.util.List<Filter<T>> filters)
      Initializes the supplied Filters by assigning the given Log.
      static <T> void initialize​(org.apache.maven.plugin.logging.Log log, Filter<T>... filters)
      Initializes the supplied Filters by assigning the given Log.
      static <T> boolean matchAtLeastOnce​(T object, java.util.List<Filter<T>> filters)
      Algorithms for accepting the supplied object if at least one of the supplied Filters accepts it.
      static <T> boolean noFilterMatches​(T object, java.util.List<Filter<T>> filters)
      Algorithms for rejecting the supplied object if at least one of the supplied Filters rejects it.
      static <T> boolean rejectAtLeastOnce​(T object, java.util.List<Filter<T>> filters)
      Algorithms for rejecting the supplied object if at least one of the supplied Filters does not accept it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Filters

        public Filters()
    • Method Detail

      • matchAtLeastOnce

        public static <T> boolean matchAtLeastOnce​(T object,
                                                   java.util.List<Filter<T>> filters)
        Algorithms for accepting the supplied object if at least one of the supplied Filters accepts it.
        Type Parameters:
        T - The Filter type.
        Parameters:
        object - The object to accept (or not).
        filters - The non-null list of Filters to examine the supplied object.
        Returns:
        true if at least one of the filters return true from its accept method.
        See Also:
        Filter.accept(Object)
      • rejectAtLeastOnce

        public static <T> boolean rejectAtLeastOnce​(T object,
                                                    java.util.List<Filter<T>> filters)
        Algorithms for rejecting the supplied object if at least one of the supplied Filters does not accept it.
        Type Parameters:
        T - The Filter type.
        Parameters:
        object - The object to reject (or not).
        filters - The non-null list of Filters to examine the supplied object.
        Returns:
        true if at least one of the filters returns false from its accept method.
        See Also:
        Filter.accept(Object)
      • noFilterMatches

        public static <T> boolean noFilterMatches​(T object,
                                                  java.util.List<Filter<T>> filters)
        Algorithms for rejecting the supplied object if at least one of the supplied Filters rejects it.
        Type Parameters:
        T - The Filter type.
        Parameters:
        object - The object to accept (or not).
        filters - The non-null list of Filters to examine the supplied object.
        Returns:
        true if at least one of the filters return false from its accept method.
        See Also:
        Filter.accept(Object)
      • adapt

        public static java.io.FileFilter adapt​(Filter<java.io.File> toAdapt)
        Adapts the Filter specification to the FileFilter interface, to enable immediate use for filtering File lists.
        Parameters:
        toAdapt - The non-null Filter which should be adapted to a FileFilter interface.
        Returns:
        If the toAdapt instance already implements the FileFilter interface, simply return the toAdapt instance. Otherwise, returns a FileFilter interface which delegates its execution to the wrapped Filter.
      • adapt

        public static java.util.List<java.io.FileFilter> adapt​(java.util.List<Filter<java.io.File>> toAdapt)
        Adapts the supplied List of Filter specifications to a List of FileFilters.
        Parameters:
        toAdapt - The List of Filters to adapts.
        Returns:
        A List holding FileFilter instances. If toAdapt is null or empty, an empty list is returned from this method. Thus, this method will never return a null value.
      • initialize

        public static <T> void initialize​(org.apache.maven.plugin.logging.Log log,
                                          java.util.List<Filter<T>> filters)
        Initializes the supplied Filters by assigning the given Log.
        Type Parameters:
        T - The Filter type.
        Parameters:
        log - The active Maven Log.
        filters - The List of Filters to initialize.
      • initialize

        public static <T> void initialize​(org.apache.maven.plugin.logging.Log log,
                                          Filter<T>... filters)
        Initializes the supplied Filters by assigning the given Log.
        Type Parameters:
        T - The Filter type.
        Parameters:
        log - The active Maven Log.
        filters - The List of Filters to initialize.