Class WriteableCacheCollectionMapper<E,R>

java.lang.Object
java.util.AbstractCollection<R>
org.infinispan.commons.util.CollectionMapper<E,R>
org.infinispan.util.WriteableCacheCollectionMapper<E,R>
Type Parameters:
E - the original collection type - referred to as old in some methods
R - the resulting collection type - referred to as new in some methods
All Implemented Interfaces:
Iterable<R>, Collection<R>, CacheCollection<R>, org.infinispan.commons.util.CloseableIteratorCollection<R>
Direct Known Subclasses:
WriteableCacheSetMapper

public class WriteableCacheCollectionMapper<E,R> extends org.infinispan.commons.util.CollectionMapper<E,R> implements CacheCollection<R>
A writeable cache collection mapper that also has constant time operations for things such as Collection.contains(Object) if the underlying Collection does.

This collection should be used for cases when a simple transformation of a element to another is all that is needed by the underlying collection.

Note this class allows for a different function specifically for values returned from an iterator. This can be useful to intercept calls such as Map.Entry.setValue(Object) and update appropriately.

Since:
9.2
Author:
wburns
  • Field Details

    • realCacheCollection

      protected final CacheCollection<E> realCacheCollection
    • toNewTypeIteratorFunction

      protected final Function<? super E, ? extends R> toNewTypeIteratorFunction
    • fromNewTypeFunction

      protected final Function<? super R, ? extends E> fromNewTypeFunction
    • keyFilterMapper

      protected final org.infinispan.commons.util.InjectiveFunction<Object,?> keyFilterMapper
  • Constructor Details

    • WriteableCacheCollectionMapper

      public WriteableCacheCollectionMapper(CacheCollection<E> realCollection, Function<? super E, ? extends R> toNewTypeFunction, Function<? super R, ? extends E> fromNewTypeFunction, org.infinispan.commons.util.InjectiveFunction<Object,?> keyFilterFunction)
    • WriteableCacheCollectionMapper

      public WriteableCacheCollectionMapper(CacheCollection<E> realCollection, Function<? super E, ? extends R> toNewTypeFunction, Function<? super E, ? extends R> toNewTypeIteratorFunction, Function<? super R, ? extends E> fromNewTypeFunction, org.infinispan.commons.util.InjectiveFunction<Object,?> keyFilterFunction)
  • Method Details

    • iterator

      public org.infinispan.commons.util.CloseableIterator<R> iterator()
      Specified by:
      iterator in interface org.infinispan.commons.util.CloseableIteratorCollection<E>
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Overrides:
      iterator in class org.infinispan.commons.util.CollectionMapper<E,R>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<E>
      Overrides:
      contains in class AbstractCollection<R>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<E>
      Overrides:
      containsAll in class AbstractCollection<R>
    • add

      public boolean add(R e)
      Specified by:
      add in interface Collection<E>
      Overrides:
      add in class org.infinispan.commons.util.CollectionMapper<E,R>
    • addAll

      public boolean addAll(Collection<? extends R> c)
      Specified by:
      addAll in interface Collection<E>
      Overrides:
      addAll in class org.infinispan.commons.util.CollectionMapper<E,R>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<E>
      Overrides:
      remove in class org.infinispan.commons.util.CollectionMapper<E,R>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<E>
      Overrides:
      removeAll in class org.infinispan.commons.util.CollectionMapper<E,R>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<E>
      Overrides:
      retainAll in class org.infinispan.commons.util.CollectionMapper<E,R>
    • removeIf

      public boolean removeIf(Predicate<? super R> filter)
      Specified by:
      removeIf in interface Collection<E>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
      Overrides:
      clear in class org.infinispan.commons.util.CollectionMapper<E,R>
    • spliterator

      public org.infinispan.commons.util.CloseableSpliterator<R> spliterator()
      Specified by:
      spliterator in interface org.infinispan.commons.util.CloseableIteratorCollection<E>
      Specified by:
      spliterator in interface Collection<E>
      Specified by:
      spliterator in interface Iterable<E>
      Overrides:
      spliterator in class org.infinispan.commons.util.CollectionMapper<E,R>
    • stream

      public CacheStream<R> stream()
      Specified by:
      stream in interface CacheCollection<E>
      Specified by:
      stream in interface org.infinispan.commons.util.CloseableIteratorCollection<E>
      Specified by:
      stream in interface Collection<E>
      Overrides:
      stream in class org.infinispan.commons.util.CollectionMapper<E,R>
    • parallelStream

      public CacheStream<R> parallelStream()
      Specified by:
      parallelStream in interface CacheCollection<E>
      Specified by:
      parallelStream in interface org.infinispan.commons.util.CloseableIteratorCollection<E>
      Specified by:
      parallelStream in interface Collection<E>
      Overrides:
      parallelStream in class org.infinispan.commons.util.CollectionMapper<E,R>