Package com.tangosol.util
Class Filters
- java.lang.Object
-
- com.tangosol.util.Filters
-
public class Filters extends Object
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 ofFilter
classes.- Author:
- as 2014.06.15
-
-
Constructor Summary
Constructors Constructor Description Filters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Filter<T>
all(Filter<? super T>... filters)
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>
any(Filter<? super T>... filters)
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>equal(String fieldName, E value)
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>
not(Filter<T> filter)
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>
script(String sLanguage, String sScriptPath, Object... aoArgs)
Instantiate a Filter that is implemented in a script using the specified language.
-
-
-
Method Detail
-
all
public static <T> Filter<T> all(Filter<? super T>... filters)
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:
AllFilter
-
any
public static <T> Filter<T> any(Filter<? super T>... filters)
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:
AnyFilter
-
always
public static <T> Filter<T> always()
Return a filter that always evaluates to true.- Returns:
- a filter that always evaluates to true
- See Also:
AlwaysFilter
-
never
public static <T> Filter<T> never()
Return a filter that always evaluates to false.- Returns:
- a filter that always evaluates to false
- See Also:
NeverFilter
-
present
public static <T> Filter<T> 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:
PresentFilter
-
not
public static <T> Filter<T> not(Filter<T> filter)
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:
NotFilter
-
isNull
public static <T,E> Filter<T> isNull(ValueExtractor<T,E> extractor)
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:
IsNullFilter
-
isNotNull
public static <T,E> Filter<T> isNotNull(ValueExtractor<T,E> extractor)
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:
IsNotNullFilter
-
isTrue
public static <T> Filter<T> isTrue(ValueExtractor<T,Boolean> extractor)
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
public static <T> Filter<T> isFalse(ValueExtractor<T,Boolean> extractor)
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
public static <T,E> Filter<T> equal(String fieldName, E value)
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:
EqualsFilter
,UniversalExtractor
-
equal
public static <T,E> Filter<T> equal(ValueExtractor<T,? extends E> extractor, E value)
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:
EqualsFilter
-
notEqual
public static <T,E> Filter<T> notEqual(ValueExtractor<T,? extends E> extractor, E value)
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:
NotEqualsFilter
-
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:
LessFilter
-
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:
LessEqualsFilter
-
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:
GreaterFilter
-
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:
GreaterEqualsFilter
-
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:
BetweenFilter
-
contains
public 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.- 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:
ContainsFilter
-
arrayContains
public 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.- 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:
ContainsFilter
-
containsAll
public 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.- 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:
ContainsAllFilter
-
containsAll
@SafeVarargs public 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.- 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:
ContainsAllFilter
-
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:
ContainsAllFilter
-
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:
ContainsAllFilter
-
containsAny
public 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.- 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:
ContainsAnyFilter
-
containsAny
@SafeVarargs public 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.- 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:
ContainsAnyFilter
-
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:
ContainsAnyFilter
-
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:
ContainsAnyFilter
-
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:
ContainsAnyFilter
-
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:
ContainsAnyFilter
-
like
public static <T,E> Filter<T> like(ValueExtractor<T,E> extractor, String sPattern)
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
public static <T,E> Filter<T> like(ValueExtractor<T,E> extractor, String sPattern, char chEscape)
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
public static <T,E> Filter<T> regex(ValueExtractor<T,E> extractor, String sRegex)
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
public static <T> Filter<T> predicate(Remote.Predicate<T> 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
public static <V> Filter<V> script(String sLanguage, String sScriptPath, Object... aoArgs)
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
-
-