Package de.espirit.common.util
Class Filter.Util
java.lang.Object
de.espirit.common.util.Filter.Util
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 TypeMethodDescriptionstatic <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>
Factory to create a combinatorial conjunction-filter on the given arguments.static <T,
C extends Collection<T>>
CdoFilter
(@NotNull Collection<T> source, @NotNull Filter<T> filter, C target) Copies all matching entries of collectionsource
to collectiontarget
.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>
Factory to create a logical consequence based filter on a given condition and its implication.static <T> @NotNull Filter<T>
Factory to create a negation of the given filter.static <T> @NotNull Filter<T>
notNull()
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>
Factory to create a combinatorial disjunction-filter on the given arguments.
-
Method Details
-
and
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
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
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
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
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 collectionsource
to collectiontarget
.- Parameters:
source
- source collectionfilter
- filter - only matching entries will be copiedtarget
- target collection- Returns:
- the target collection
- Since:
- 4.1.9
-
equal
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
A primitive filter accepting any element.- Returns:
- An all element accepting filter.
- Since:
- 4.1.9
-
acceptNothing
A primitive filter accepting no element.- Returns:
- A no element accepting filter.
- Since:
- 4.1.10
-
notNull
A primitive filter accepting all non-null elements.- Returns:
- A non null filter.
- Since:
- 4.1.9
-