Class CacheFilters

    • Method Detail

      • predicate

        public static <K,​V> Predicate<CacheEntry<K,​V>> predicate​(KeyValueFilter<? super K,​? super V> filter)
        Creates a new Predicate using the provided key value filter as a basis for the operation. This is useful for when using Stream.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 type
        V - value type
        Parameters:
        filter - the filter to utilize
        Returns:
        predicate based on the filter
      • function

        public static <K,​V,​C> Function<CacheEntry<K,​V>,​CacheEntry<K,​C>> function​(Converter<? super K,​? super V,​C> converter)
        Creates a new Function using the provided converter as a basis for the operation. This is useful for when using Stream.map(Function) method on distributed streams. The key, value and metadata are all used to determine the converted value.
        Type Parameters:
        K - key type
        V - value type
        C - converted value type
        Parameters:
        converter - the converter to utilize
        Returns:
        function based on the converter
      • notNullCacheEntryPredicate

        public static <K,​V> Predicate<CacheEntry<K,​V>> notNullCacheEntryPredicate()
        Provides a predicate that can be used to filter out null cache entry objects as well as placeholder "null" entries of NullCacheEntry that can be returned from methods such as converterToFunction(KeyValueFilterConverter).
        Type Parameters:
        K - entry key type
        V - entry value type
        Returns:
        a predicate to filter null entries
      • filterAndConvert

        public 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. This method keeps the contract of filter and conversion being performed in only 1 call as the KeyValueFilterConverter 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 on
        filterConverter - converter to apply
        Returns: