Interface Filter<T>

All Known Subinterfaces:
ClassNameFilter, DiscoveryFilter<T>, PackageNameFilter, PostDiscoveryFilter
All Known Implementing Classes:
EngineFilter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @API(status=STABLE, since="1.0") public interface Filter<T>
A Filter can be applied to determine if an object should be included or excluded in a result set.

For example, tests may be filtered during or after test discovery based on certain criteria.

Clients should not implement this interface directly but rather one of its subinterfaces.

Since:
1.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, V> Filter<T>
    adaptFilter(Filter<V> adaptee, Function<T,V> converter)
    Return a filter that will include elements if and only if the adapted Filter includes the value converted using the supplied Function.
    apply(T object)
    Apply this filter to the supplied object.
    static <T> Filter<T>
    composeFilters(Collection<? extends Filter<T>> filters)
    Return a filter that will include elements if and only if all of the filters in the supplied collection of filters include it.
    static <T> Filter<T>
    composeFilters(Filter<T>... filters)
    Return a filter that will include elements if and only if all of the filters in the supplied array of filters include it.
    default Predicate<T>
    Return a Predicate that returns true if this filter includes the object supplied to the predicate's test method.
  • Method Details

    • composeFilters

      @SafeVarargs static <T> Filter<T> composeFilters(Filter<T>... filters)
      Return a filter that will include elements if and only if all of the filters in the supplied array of filters include it.

      If the array is empty, the returned filter will include all elements it is asked to filter.

      Parameters:
      filters - the array of filters to compose; never null
      See Also:
    • composeFilters

      static <T> Filter<T> composeFilters(Collection<? extends Filter<T>> filters)
      Return a filter that will include elements if and only if all of the filters in the supplied collection of filters include it.

      If the collection is empty, the returned filter will include all elements it is asked to filter.

      Parameters:
      filters - the collection of filters to compose; never null
      See Also:
    • adaptFilter

      static <T, V> Filter<T> adaptFilter(Filter<V> adaptee, Function<T,V> converter)
      Return a filter that will include elements if and only if the adapted Filter includes the value converted using the supplied Function.
      Parameters:
      adaptee - the filter to be adapted
      converter - the converter function to apply
    • apply

      FilterResult apply(T object)
      Apply this filter to the supplied object.
    • toPredicate

      default Predicate<T> toPredicate()
      Return a Predicate that returns true if this filter includes the object supplied to the predicate's test method.