Package org.infinispan.filter
Class CacheFilters
java.lang.Object
org.infinispan.filter.CacheFilters
Static factory class that contains utility methods that can be used for performing proper transformations from
KeyValueFilter
, Converter
and KeyValueFilterConverter
to appropriate distributed stream
instances.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V, C> Function <CacheEntry<K, V>, CacheEntry<K, C>> converterToFunction
(KeyValueFilterConverter<? super K, ? super V, C> filterConverter) Creates a newFunction
using the provided filter convert.static <K,
V, C> Stream <CacheEntry<K, C>> filterAndConvert
(Stream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) Adds needed intermediate operations to the provided stream, returning a possibly new stream as a result of the operations.static <K,
V, C> CacheStream <CacheEntry<K, C>> filterAndConvert
(CacheStream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) static <K,
V, C> CacheStream <K> filterAndConvertToKey
(CacheStream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) static <K,
V, C> CacheStream <C> filterAndConvertToValue
(CacheStream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) static <K,
V, C> Function <CacheEntry<K, V>, CacheEntry<K, C>> Creates a newFunction
using the provided converter as a basis for the operation.static <K,
V> Predicate <CacheEntry<K, V>> Provides a predicate that can be used to filter out null cache entry objects as well as placeholder "null" entries ofNullCacheEntry
that can be returned from methods such asconverterToFunction(KeyValueFilterConverter)
.static <K,
V> Predicate <CacheEntry<K, V>> predicate
(KeyValueFilter<? super K, ? super V> filter) Creates a newPredicate
using the provided key value filter as a basis for the operation.
-
Method Details
-
predicate
public static <K,V> Predicate<CacheEntry<K,V>> predicate(KeyValueFilter<? super K, ? super V> filter) Creates a newPredicate
using the provided key value filter as a basis for the operation. This is useful for when usingStream.filter(Predicate)
method on distributed streams. The key, value and metadata are all used to determine if the predicate returns true or not.- Type Parameters:
K
- key typeV
- value type- Parameters:
filter
- the filter to utilize- Returns:
- predicate based on the filter
-
function
public static <K,V, Function<CacheEntry<K,C> V>, functionCacheEntry<K, C>> (Converter<? super K, ? super V, C> converter) Creates a newFunction
using the provided converter as a basis for the operation. This is useful for when usingStream.map(Function)
method on distributed streams. The key, value and metadata are all used to determine the converted value.- Type Parameters:
K
- key typeV
- value typeC
- converted value type- Parameters:
converter
- the converter to utilize- Returns:
- function based on the converter
-
converterToFunction
public static <K,V, Function<CacheEntry<K,C> V>, converterToFunctionCacheEntry<K, C>> (KeyValueFilterConverter<? super K, ? super V, C> filterConverter) Creates a newFunction
using the provided filter convert. TheKeyValueFilterConverter.filterAndConvert(Object, Object, Metadata)
is invoked for every passed in CacheEntry. When a null value is returned from the filter converter instead of a nullCacheEntry
being returned, we instead return theNullCacheEntry
as a sign of it. This allows thisFunction
to be used in cases when a null value cannot be returned, such as reactive streams.The
notNullCacheEntryPredicate()
can be used to filter these values if needed.- Type Parameters:
K
- key typeV
- value typeC
- converted value type- Parameters:
filterConverter
- the filter converter to utilize- Returns:
- function based on the filter converter
-
notNullCacheEntryPredicate
Provides a predicate that can be used to filter out null cache entry objects as well as placeholder "null" entries ofNullCacheEntry
that can be returned from methods such asconverterToFunction(KeyValueFilterConverter)
.- Type Parameters:
K
- entry key typeV
- entry value type- Returns:
- a predicate to filter null entries
-
filterAndConvertToKey
public static <K,V, CacheStream<K> filterAndConvertToKeyC> (CacheStream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) -
filterAndConvertToValue
public static <K,V, CacheStream<C> filterAndConvertToValueC> (CacheStream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) -
filterAndConvert
public static <K,V, Stream<CacheEntry<K,C> C>> filterAndConvert(Stream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter) Adds needed intermediate operations to the provided stream, returning a possibly new stream as a result of the operations. This method keeps the contract of filter and conversion being performed in only 1 call as theKeyValueFilterConverter
was designed to do. The key, value and metadata are all used to determine whether the value is returned and the converted value.- Type Parameters:
K
-V
-C
-- Parameters:
stream
- stream to perform the operations onfilterConverter
- converter to apply- Returns:
-
filterAndConvert
public static <K,V, CacheStream<CacheEntry<K,C> C>> filterAndConvert(CacheStream<CacheEntry<K, V>> stream, KeyValueFilterConverter<? super K, ? super V, C> filterConverter)
-