Package com.tangosol.util
Class Filters
java.lang.Object
com.tangosol.util.Filters
Simple Filter DSL.
The methods in this class are for the most part simple factory methods for
various Filter
classes, but in some cases provide additional type
safety. They also tend to make the code more readable, especially if imported
statically, so their use is strongly encouraged in lieu of direct construction
of Filter
classes.
- Author:
- as 2014.06.15
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Filter
<T> Return a composite filter representing logical AND of all specified filters.static <T> Filter
<T> always()
Return a filter that always evaluates to true.static <T> Filter
<T> Return a composite filter representing logical OR of all specified filters.static <T,
E> Filter <T> arrayContains
(ValueExtractor<T, E[]> extractor, E value) Return a filter that tests if the extracted array contains the specified value.static <T,
E> Filter <T> arrayContainsAll
(ValueExtractor<T, E[]> extractor, E... values) Return a filter that tests if the extracted array contains all of the specified values.static <T,
E> Filter <T> arrayContainsAll
(ValueExtractor<T, E[]> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted array contains all of the specified values.static <T,
E> Filter <T> arrayContainsAny
(ValueExtractor<T, E[]> extractor, E... values) Return a filter that tests if the extracted array contains any of the specified values.static <T,
E> Filter <T> arrayContainsAny
(ValueExtractor<T, E[]> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted array contains any of the specified values.static <T,
E extends Comparable<? super E>>
Filter<T> between
(ValueExtractor<T, ? extends E> extractor, E from, E to) Return a filter that tests if the extracted value is between the specified values (inclusive).static <T,
E, C extends Collection<? extends E>>
Filter<T> contains
(ValueExtractor<T, C> extractor, E value) Return a filter that tests if the extracted collection contains the specified value.static <T,
E, C extends Collection<? extends E>>
Filter<T> containsAll
(ValueExtractor<T, C> extractor, E... values) Return a filter that tests if the extracted collection contains all of the specified values.static <T,
E, C extends Collection<? extends E>>
Filter<T> containsAll
(ValueExtractor<T, C> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted collection contains all of the specified values.static <T,
E, C extends Collection<? extends E>>
Filter<T> containsAny
(ValueExtractor<T, C> extractor, E... values) Return a filter that tests if the extracted collection contains any of the specified values.static <T,
E, C extends Collection<? extends E>>
Filter<T> containsAny
(ValueExtractor<T, C> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted collection contains any of the specified values.static <T,
E> Filter <T> equal
(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests for equality.static <T,
E> Filter <T> Return a filter that tests for equality using aUniversalExtractor
instance to extract the specified field.static <T,
E extends Comparable<? super E>>
Filter<T> greater
(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is greater than the specified value.static <T,
E extends Comparable<? super E>>
Filter<T> greaterEqual
(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is greater than or equal to the specified value.static <T,
E> Filter <T> in
(ValueExtractor<T, ? extends E> extractor, E... values) Return a filter that tests if the extracted value is contained in the specified array.static <T,
E> Filter <T> in
(ValueExtractor<T, ? extends E> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted value is contained in the specified set.static <T> Filter
<T> isFalse
(ValueExtractor<T, Boolean> extractor) Return a filter that evaluates to true if the extracted value isfalse
.static <T,
E> Filter <T> isNotNull
(ValueExtractor<T, E> extractor) Return a filter that evaluates to true for non-null values.static <T,
E> Filter <T> isNull
(ValueExtractor<T, E> extractor) Return a filter that evaluates to true for null values.static <T> Filter
<T> isTrue
(ValueExtractor<T, Boolean> extractor) Return a filter that evaluates to true if the extracted value istrue
.static <T,
E extends Comparable<? super E>>
Filter<T> less
(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is less than the specified value.static <T,
E extends Comparable<? super E>>
Filter<T> lessEqual
(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is less than or equal to the specified value.static <T,
E> Filter <T> like
(ValueExtractor<T, E> extractor, String sPattern) Return a LikeFilter for pattern match.static <T,
E> Filter <T> like
(ValueExtractor<T, E> extractor, String sPattern, boolean fIgnoreCase) Return a LikeFilter for pattern match.static <T,
E> Filter <T> like
(ValueExtractor<T, E> extractor, String sPattern, char chEscape) Return a LikeFilter for pattern match.static <T,
E> Filter <T> like
(ValueExtractor<T, E> extractor, String sPattern, char chEscape, boolean fIgnoreCase) Return a LikeFilter for pattern match.static <T> Filter
<T> never()
Return a filter that always evaluates to false.static <T> Filter
<T> Return a filter that represents the logical negation of the specified filter.static <T,
E> Filter <T> notEqual
(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests for non-equality.static <T> Filter
<T> predicate
(Remote.Predicate<T> predicate) Return a PredicateFilter for a givenPredicate
.static <T,
E> Filter <T> predicate
(ValueExtractor<T, ? extends E> extractor, Remote.Predicate<? super E> predicate) Return a PredicateFilter for a givenPredicate
.static <T> Filter
<T> present()
Return a filter that evaluates to true if an entry is present in the cache.static <T,
E> Filter <T> regex
(ValueExtractor<T, E> extractor, String sRegex) Return a RegexFilter for pattern match.static <V> Filter
<V> Instantiate a Filter that is implemented in a script using the specified language.
-
Constructor Details
-
Filters
public Filters()
-
-
Method Details
-
all
Return a composite filter representing logical AND of all specified filters.- Parameters:
filters
- an array of filters- Returns:
- a composite filter representing logical AND of all specified filters
- See Also:
-
any
Return a composite filter representing logical OR of all specified filters.- Parameters:
filters
- an array of filters- Returns:
- a composite filter representing logical OR of all specified filters
- See Also:
-
always
Return a filter that always evaluates to true.- Returns:
- a filter that always evaluates to true
- See Also:
-
never
Return a filter that always evaluates to false.- Returns:
- a filter that always evaluates to false
- See Also:
-
present
Return a filter that evaluates to true if an entry is present in the cache.- Returns:
- a filter that evaluates to true if an entry is present
- See Also:
-
not
Return a filter that represents the logical negation of the specified filter.- Type Parameters:
T
- the type of the input argument to the filter- Parameters:
filter
- the filter- Returns:
- a filter that represents the logical negation of the specified filter
- See Also:
-
isNull
Return a filter that evaluates to true for null values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the Extractor to use- Returns:
- a filter that evaluates to true for null values
- See Also:
-
isNotNull
Return a filter that evaluates to true for non-null values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the Extractor to use- Returns:
- a filter that evaluates to true for non-null values
- See Also:
-
isTrue
Return a filter that evaluates to true if the extracted value istrue
.- Type Parameters:
T
- the type of the object to extract value from- Parameters:
extractor
- the Extractor to use- Returns:
- a filter that evaluates to true for non-null values
-
isFalse
Return a filter that evaluates to true if the extracted value isfalse
.- Type Parameters:
T
- the type of the object to extract value from- Parameters:
extractor
- the Extractor to use- Returns:
- a filter that evaluates to true for non-null values
-
equal
Return a filter that tests for equality using aUniversalExtractor
instance to extract the specified field.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
fieldName
- the name of the field to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests for equality
- See Also:
-
equal
Return a filter that tests for equality.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the Extractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests for equality
- See Also:
-
notEqual
Return a filter that tests for non-equality.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests for non-equality
- See Also:
-
less
public static <T,E extends Comparable<? super E>> Filter<T> less(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is less than the specified value.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests if the extracted value is less than the specified value
- See Also:
-
lessEqual
public static <T,E extends Comparable<? super E>> Filter<T> lessEqual(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is less than or equal to the specified value.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests if the extracted value is less than or equal to the specified value
- See Also:
-
greater
public static <T,E extends Comparable<? super E>> Filter<T> greater(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is greater than the specified value.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests if the extracted value is greater than the specified value
- See Also:
-
greaterEqual
public static <T,E extends Comparable<? super E>> Filter<T> greaterEqual(ValueExtractor<T, ? extends E> extractor, E value) Return a filter that tests if the extracted value is greater than or equal to the specified value.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests if the extracted value is greater than or equal to the specified value
- See Also:
-
between
public static <T,E extends Comparable<? super E>> Filter<T> between(ValueExtractor<T, ? extends E> extractor, E from, E to) Return a filter that tests if the extracted value is between the specified values (inclusive).- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usefrom
- the lower bound to compare the extracted value withto
- the upper bound to compare the extracted value with- Returns:
- a filter that tests if the extracted value is between the specified values
- See Also:
-
contains
public static <T,E, Filter<T> containsC extends Collection<? extends E>> (ValueExtractor<T, C> extractor, E value) Return a filter that tests if the extracted collection contains the specified value.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted valueC
- the type of value that will be extracted by the extractor- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests if the extracted collection contains the specified value
- See Also:
-
arrayContains
Return a filter that tests if the extracted array contains the specified value.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalue
- the value to compare the extracted value with- Returns:
- a filter that tests if the extracted array contains the specified value
- See Also:
-
containsAll
public static <T,E, Filter<T> containsAllC extends Collection<? extends E>> (ValueExtractor<T, C> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted collection contains all of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted valueC
- the type of value that will be extracted by the extractor- Parameters:
extractor
- the ValueExtractor to usesetValues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted collection contains all of the specified values
- See Also:
-
containsAll
@SafeVarargs public static <T,E, Filter<T> containsAllC extends Collection<? extends E>> (ValueExtractor<T, C> extractor, E... values) Return a filter that tests if the extracted collection contains all of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted valueC
- the type of value that will be extracted by the extractor- Parameters:
extractor
- the ValueExtractor to usevalues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted collection contains all of the specified values
- See Also:
-
arrayContainsAll
public static <T,E> Filter<T> arrayContainsAll(ValueExtractor<T, E[]> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted array contains all of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usesetValues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted array contains all of the specified values
- See Also:
-
arrayContainsAll
@SafeVarargs public static <T,E> Filter<T> arrayContainsAll(ValueExtractor<T, E[]> extractor, E... values) Return a filter that tests if the extracted array contains all of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted array contains all of the specified value
- See Also:
-
containsAny
public static <T,E, Filter<T> containsAnyC extends Collection<? extends E>> (ValueExtractor<T, C> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted collection contains any of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted valueC
- the type of value that will be extracted by the extractor- Parameters:
extractor
- the ValueExtractor to usesetValues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted collection contains any of the specified values
- See Also:
-
containsAny
@SafeVarargs public static <T,E, Filter<T> containsAnyC extends Collection<? extends E>> (ValueExtractor<T, C> extractor, E... values) Return a filter that tests if the extracted collection contains any of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted valueC
- the type of value that will be extracted by the extractor- Parameters:
extractor
- the ValueExtractor to usevalues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted collection contains any of the specified values
- See Also:
-
arrayContainsAny
public static <T,E> Filter<T> arrayContainsAny(ValueExtractor<T, E[]> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted array contains any of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usesetValues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted array contains any of the specified values
- See Also:
-
arrayContainsAny
@SafeVarargs public static <T,E> Filter<T> arrayContainsAny(ValueExtractor<T, E[]> extractor, E... values) Return a filter that tests if the extracted array contains any of the specified values.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted array contains any of the specified values
- See Also:
-
in
public static <T,E> Filter<T> in(ValueExtractor<T, ? extends E> extractor, Set<? extends E> setValues) Return a filter that tests if the extracted value is contained in the specified set.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usesetValues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted value is contained in the specified set
- See Also:
-
in
@SafeVarargs public static <T,E> Filter<T> in(ValueExtractor<T, ? extends E> extractor, E... values) Return a filter that tests if the extracted value is contained in the specified array.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to usevalues
- the values to compare the extracted value with- Returns:
- a filter that tests if the extracted value is contained in the specified array
- See Also:
-
like
Return a LikeFilter for pattern match.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the Extractor to use by this filtersPattern
- the string pattern to compare the result with- Returns:
- a LikeFilter
-
like
Return a LikeFilter for pattern match.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to use by this filtersPattern
- the string pattern to compare the result withchEscape
- the escape character for escaping '%' and '_'- Returns:
- a LikeFilter
-
like
public static <T,E> Filter<T> like(ValueExtractor<T, E> extractor, String sPattern, boolean fIgnoreCase) Return a LikeFilter for pattern match.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to use by this filtersPattern
- the string pattern to compare the result withfIgnoreCase
- true to be case-insensitive- Returns:
- a LikeFilter
-
like
public static <T,E> Filter<T> like(ValueExtractor<T, E> extractor, String sPattern, char chEscape, boolean fIgnoreCase) Return a LikeFilter for pattern match.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to use by this filtersPattern
- the string pattern to compare the result withchEscape
- the escape character for escaping '%' and '_'fIgnoreCase
- true to be case-insensitive- Returns:
- a LikeFilter
-
regex
Return a RegexFilter for pattern match.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value- Parameters:
extractor
- the ValueExtractor to use by this filtersRegex
- the regular expression to match the result with- Returns:
- a RegexFilter
-
predicate
Return a PredicateFilter for a givenPredicate
.- Type Parameters:
T
- the type of the object to evaluate- Parameters:
predicate
- the predicate to evaluate- Returns:
- a RegexFilter
-
predicate
public static <T,E> Filter<T> predicate(ValueExtractor<T, ? extends E> extractor, Remote.Predicate<? super E> predicate) Return a PredicateFilter for a givenPredicate
.- Type Parameters:
T
- the type of the object to extract value fromE
- the type of extracted value to evaluate- Parameters:
extractor
- the ValueExtractor to use by this filterpredicate
- the predicate to evaluate- Returns:
- a RegexFilter
-
script
Instantiate a Filter that is implemented in a script using the specified language.- Type Parameters:
V
- the type of value that theFilter
will receive- Parameters:
sLanguage
- the string specifying one of the supported languagessScriptPath
- the path where the script reside, relative to rootaoArgs
- the arguments to be passed to the script- Returns:
- An instance of
Filter
- Throws:
ScriptException
- if thescript
cannot be loaded or any error occurs during its executionIllegalArgumentException
- if the specified language is not supported- Since:
- 14.1.1.0
-