Class WriteableCacheCollectionMapper<E,R>
- java.lang.Object
-
- java.util.AbstractCollection<R>
-
- org.infinispan.util.CollectionMapper<E,R>
-
- org.infinispan.util.WriteableCacheCollectionMapper<E,R>
-
- Type Parameters:
E- the original collection type - referred to as old in some methodsR- the resulting collection type - referred to as new in some methods
- All Implemented Interfaces:
Iterable<R>,Collection<R>,CacheCollection<R>,CloseableIteratorCollection<R>
- Direct Known Subclasses:
WriteableCacheSetMapper
public class WriteableCacheCollectionMapper<E,R> extends CollectionMapper<E,R> implements CacheCollection<R>
A writeable cache collection mapper that also has constant time operations for things such asCollection.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 Summary
Fields Modifier and Type Field Description protected Function<? super R,? extends E>fromNewTypeFunctionprotected InjectiveFunction<Object,?>keyFilterMapperprotected CacheCollection<E>realCacheCollectionprotected Function<? super E,? extends R>toNewTypeIteratorFunction-
Fields inherited from class org.infinispan.util.CollectionMapper
mapper, realCollection
-
-
Constructor Summary
Constructors Constructor Description WriteableCacheCollectionMapper(CacheCollection<E> realCollection, Function<? super E,? extends R> toNewTypeFunction, Function<? super E,? extends R> toNewTypeIteratorFunction, Function<? super R,? extends E> fromNewTypeFunction, InjectiveFunction<Object,?> keyFilterFunction)WriteableCacheCollectionMapper(CacheCollection<E> realCollection, Function<? super E,? extends R> toNewTypeFunction, Function<? super R,? extends E> fromNewTypeFunction, InjectiveFunction<Object,?> keyFilterFunction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(R e)booleanaddAll(Collection<? extends R> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)CloseableIterator<R>iterator()CacheStream<R>parallelStream()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanremoveIf(Predicate<? super R> filter)booleanretainAll(Collection<?> c)CloseableSpliterator<R>spliterator()CacheStream<R>stream()-
Methods inherited from class org.infinispan.util.CollectionMapper
forEach, isEmpty, size
-
Methods inherited from class java.util.AbstractCollection
toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
realCacheCollection
protected final CacheCollection<E> realCacheCollection
-
toNewTypeIteratorFunction
protected final Function<? super E,? extends R> toNewTypeIteratorFunction
-
keyFilterMapper
protected final InjectiveFunction<Object,?> keyFilterMapper
-
-
Constructor Detail
-
WriteableCacheCollectionMapper
public WriteableCacheCollectionMapper(CacheCollection<E> realCollection, Function<? super E,? extends R> toNewTypeFunction, Function<? super R,? extends E> fromNewTypeFunction, 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, InjectiveFunction<Object,?> keyFilterFunction)
-
-
Method Detail
-
iterator
public CloseableIterator<R> iterator()
Description copied from interface:CloseableIteratorCollectionThis iterator should be explicitly closed when iteration upon it is completed. Failure to do so could cause resources to not be freed properly
- Specified by:
iteratorin interfaceCloseableIteratorCollection<E>- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Overrides:
iteratorin classCollectionMapper<E,R>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E>- Overrides:
containsin classAbstractCollection<R>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Overrides:
containsAllin classAbstractCollection<R>
-
add
public boolean add(R e)
- Specified by:
addin interfaceCollection<E>- Overrides:
addin classCollectionMapper<E,R>
-
addAll
public boolean addAll(Collection<? extends R> c)
- Specified by:
addAllin interfaceCollection<E>- Overrides:
addAllin classCollectionMapper<E,R>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<E>- Overrides:
removein classCollectionMapper<E,R>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<E>- Overrides:
removeAllin classCollectionMapper<E,R>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<E>- Overrides:
retainAllin classCollectionMapper<E,R>
-
removeIf
public boolean removeIf(Predicate<? super R> filter)
- Specified by:
removeIfin interfaceCollection<E>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classCollectionMapper<E,R>
-
spliterator
public CloseableSpliterator<R> spliterator()
Description copied from interface:CloseableIteratorCollectionThis spliterator should be explicitly closed after it has been used. Failure to do so could cause resources to not be freed properly
- Specified by:
spliteratorin interfaceCloseableIteratorCollection<E>- Specified by:
spliteratorin interfaceCollection<E>- Specified by:
spliteratorin interfaceIterable<E>- Overrides:
spliteratorin classCollectionMapper<E,R>
-
stream
public CacheStream<R> stream()
Description copied from interface:CloseableIteratorCollectionThis stream should be explicitly closed after it has been used. Failure to do so could cause resources to not be freed properly
- Specified by:
streamin interfaceCacheCollection<E>- Specified by:
streamin interfaceCloseableIteratorCollection<E>- Specified by:
streamin interfaceCollection<E>- Overrides:
streamin classCollectionMapper<E,R>
-
parallelStream
public CacheStream<R> parallelStream()
Description copied from interface:CloseableIteratorCollectionThis stream should be explicitly closed after it has been used. Failure to do so could cause resources to not be freed properly
- Specified by:
parallelStreamin interfaceCacheCollection<E>- Specified by:
parallelStreamin interfaceCloseableIteratorCollection<E>- Specified by:
parallelStreamin interfaceCollection<E>- Overrides:
parallelStreamin classCollectionMapper<E,R>
-
-