Class Filter.Util

java.lang.Object
de.espirit.common.util.Filter.Util
Enclosing interface:
Filter<T>

public static final class Filter.Util extends Object
Usage example
 import static de.espirit.common.util.Filter.Util.and; import static de.espirit.common.util.Filter.Util.doFilter; import static de.espirit.common.util.Filter.Util.not; import static de.espirit.common.util.Filter.Util.or; ... List<Integer> allResults = ...; Filter<Integer> biggerThanZero = ...; Filter<Integer> isMultipleOf_13 = ...; Filter<Integer> isOdd = ...; Filter<Integer> combinedFilter =  and(de.espirit.common.util.Filter<T>...)(biggerThanZero,  not(de.espirit.common.util.Filter<T>)( or(de.espirit.common.util.Filter<T>...)(isMultipleOf_13, isOdd))); List<Integer> filteredResult =  doFilter(java.util.Collection<T>, de.espirit.common.util.Filter<T>, C)(allResults, combinedFilter, new ArrayList<Integer>()); 
Since:
4.1.9
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> @NotNull Filter<T>
    A primitive filter accepting any element.
    static <T> @NotNull Filter<T>
    A primitive filter accepting no element.
    static <T> @NotNull Filter<T>
    and(@NotNull Collection<Filter<T>> f)
    Factory to create a combinatorial conjunction-filter on a given collection of filters.
    static <T> @NotNull Filter<T>
    and(Filter<T>... f)
    Factory to create a combinatorial conjunction-filter on the given arguments.
    static <T, C extends Collection<T>>
    C
    doFilter(@NotNull Collection<T> source, @NotNull Filter<T> filter, C target)
    Copies all matching entries of collection source to collection target.
    static <T> @NotNull Filter<T>
    equal(T value)
    Factory creating an equality filter with the given value as comparison operand.
    static <T> @NotNull Filter<T>
    implies(@NotNull Filter<T> condition, @NotNull Filter<T> implication)
    Factory to create a logical consequence based filter on a given condition and its implication.
    static <T> @NotNull Filter<T>
    not(@NotNull Filter<T> f)
    Factory to create a negation of the given filter.
    static <T> @NotNull Filter<T>
    A primitive filter accepting all non-null elements.
    static <T> @NotNull Filter<T>
    or(@NotNull Collection<Filter<T>> f)
    Factory to create a combinatorial disjunction-filter on a given collection of filters.
    static <T> @NotNull Filter<T>
    or(Filter<T>... f)
    Factory to create a combinatorial disjunction-filter on the given arguments.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • and

      @NotNull public static <T> @NotNull Filter<T> and(Filter<T>... f)
      Factory to create a combinatorial conjunction-filter on the given arguments.
      Parameters:
      f - The filters to be combined.
      Returns:
      A conjunctive filter.
      Since:
      4.1.9
    • and

      @NotNull public static <T> @NotNull Filter<T> and(@NotNull @NotNull Collection<Filter<T>> f)
      Factory to create a combinatorial conjunction-filter on a given collection of filters.
      Parameters:
      f - The filters to be combined.
      Returns:
      A conjunctive filter.
      Since:
      4.1.9
    • or

      @NotNull public static <T> @NotNull Filter<T> or(Filter<T>... f)
      Factory to create a combinatorial disjunction-filter on the given arguments.
      Parameters:
      f - The filtersr to be combined.
      Returns:
      A disjunctive filter.
      Since:
      4.1.9
    • or

      @NotNull public static <T> @NotNull Filter<T> or(@NotNull @NotNull Collection<Filter<T>> f)
      Factory to create a combinatorial disjunction-filter on a given collection of filters.
      Parameters:
      f - The filters to be combined.
      Returns:
      A disjunctive filter.
      Since:
      4.1.9
    • not

      @NotNull public static <T> @NotNull Filter<T> not(@NotNull @NotNull Filter<T> f)
      Factory to create a negation of the given filter.
      Parameters:
      f - The filter to be negated.
      Returns:
      The negating filter.
      Since:
      4.1.9
    • implies

      @NotNull public static <T> @NotNull Filter<T> implies(@NotNull @NotNull Filter<T> condition, @NotNull @NotNull Filter<T> implication)
      Factory to create a logical consequence based filter on a given condition and its implication. That is, the filter accepts an element, if either the condition fails to accept or, if it does accept the element, the implication accepts the element as well.
      Parameters:
      condition - The condition that may be accepted or not.
      implication - The implication that must be accepted.
      Returns:
      true, if the condition does not hold or the implication accepts the element.
      Since:
      4.1.9
    • doFilter

      @NotNull public static <T, C extends Collection<T>> C doFilter(@NotNull @NotNull Collection<T> source, @NotNull @NotNull Filter<T> filter, @NotNull C target)
      Copies all matching entries of collection source to collection target.
      Parameters:
      source - source collection
      filter - filter - only matching entries will be copied
      target - target collection
      Returns:
      the target collection
      Since:
      4.1.9
    • equal

      @NotNull public static <T> @NotNull Filter<T> equal(T value)
      Factory creating an equality filter with the given value as comparison operand.
      Parameters:
      value - The comparison operand.
      Returns:
      An equality filter.
      Since:
      4.1.9
    • acceptAll

      @NotNull public static <T> @NotNull Filter<T> acceptAll()
      A primitive filter accepting any element.
      Returns:
      An all element accepting filter.
      Since:
      4.1.9
    • acceptNothing

      @NotNull public static <T> @NotNull Filter<T> acceptNothing()
      A primitive filter accepting no element.
      Returns:
      A no element accepting filter.
      Since:
      4.1.10
    • notNull

      @NotNull public static <T> @NotNull Filter<T> notNull()
      A primitive filter accepting all non-null elements.
      Returns:
      A non null filter.
      Since:
      4.1.9