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:
java.lang.Iterable<R>
,java.util.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 java.util.function.Function<? super R,? extends E>
fromNewTypeFunction
protected InjectiveFunction<java.lang.Object,?>
keyFilterMapper
protected CacheCollection<E>
realCacheCollection
protected java.util.function.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, java.util.function.Function<? super E,? extends R> toNewTypeFunction, java.util.function.Function<? super E,? extends R> toNewTypeIteratorFunction, java.util.function.Function<? super R,? extends E> fromNewTypeFunction, InjectiveFunction<java.lang.Object,?> keyFilterFunction)
WriteableCacheCollectionMapper(CacheCollection<E> realCollection, java.util.function.Function<? super E,? extends R> toNewTypeFunction, java.util.function.Function<? super R,? extends E> fromNewTypeFunction, InjectiveFunction<java.lang.Object,?> keyFilterFunction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(R e)
boolean
addAll(java.util.Collection<? extends R> c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
CloseableIterator<R>
iterator()
CacheStream<R>
parallelStream()
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
removeIf(java.util.function.Predicate<? super R> filter)
boolean
retainAll(java.util.Collection<?> c)
CloseableSpliterator<R>
spliterator()
CacheStream<R>
stream()
-
Methods inherited from class org.infinispan.util.CollectionMapper
forEach, isEmpty, size
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.CacheCollection
localPublisher, localPublisher
-
-
-
-
Field Detail
-
realCacheCollection
protected final CacheCollection<E> realCacheCollection
-
toNewTypeIteratorFunction
protected final java.util.function.Function<? super E,? extends R> toNewTypeIteratorFunction
-
fromNewTypeFunction
protected final java.util.function.Function<? super R,? extends E> fromNewTypeFunction
-
keyFilterMapper
protected final InjectiveFunction<java.lang.Object,?> keyFilterMapper
-
-
Constructor Detail
-
WriteableCacheCollectionMapper
public WriteableCacheCollectionMapper(CacheCollection<E> realCollection, java.util.function.Function<? super E,? extends R> toNewTypeFunction, java.util.function.Function<? super R,? extends E> fromNewTypeFunction, InjectiveFunction<java.lang.Object,?> keyFilterFunction)
-
WriteableCacheCollectionMapper
public WriteableCacheCollectionMapper(CacheCollection<E> realCollection, java.util.function.Function<? super E,? extends R> toNewTypeFunction, java.util.function.Function<? super E,? extends R> toNewTypeIteratorFunction, java.util.function.Function<? super R,? extends E> fromNewTypeFunction, InjectiveFunction<java.lang.Object,?> keyFilterFunction)
-
-
Method Detail
-
iterator
public CloseableIterator<R> iterator()
Description copied from interface:CloseableIteratorCollection
This 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:
iterator
in interfaceCloseableIteratorCollection<E>
- Specified by:
iterator
in interfacejava.util.Collection<E>
- Specified by:
iterator
in interfacejava.lang.Iterable<E>
- Overrides:
iterator
in classCollectionMapper<E,R>
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
add
public boolean add(R e)
- Specified by:
add
in interfacejava.util.Collection<E>
- Overrides:
add
in classCollectionMapper<E,R>
-
addAll
public boolean addAll(java.util.Collection<? extends R> c)
- Specified by:
addAll
in interfacejava.util.Collection<E>
- Overrides:
addAll
in classCollectionMapper<E,R>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection<E>
- Overrides:
remove
in classCollectionMapper<E,R>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAll
in interfacejava.util.Collection<E>
- Overrides:
removeAll
in classCollectionMapper<E,R>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAll
in interfacejava.util.Collection<E>
- Overrides:
retainAll
in classCollectionMapper<E,R>
-
removeIf
public boolean removeIf(java.util.function.Predicate<? super R> filter)
- Specified by:
removeIf
in interfacejava.util.Collection<E>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<E>
- Overrides:
clear
in classCollectionMapper<E,R>
-
spliterator
public CloseableSpliterator<R> spliterator()
Description copied from interface:CloseableIteratorCollection
This spliterator should be explicitly closed after it has been used. Failure to do so could cause resources to not be freed properly
- Specified by:
spliterator
in interfaceCloseableIteratorCollection<E>
- Specified by:
spliterator
in interfacejava.util.Collection<E>
- Specified by:
spliterator
in interfacejava.lang.Iterable<E>
- Overrides:
spliterator
in classCollectionMapper<E,R>
-
stream
public CacheStream<R> stream()
Description copied from interface:CloseableIteratorCollection
This stream should be explicitly closed after it has been used. Failure to do so could cause resources to not be freed properly
- Specified by:
stream
in interfaceCacheCollection<E>
- Specified by:
stream
in interfaceCloseableIteratorCollection<E>
- Specified by:
stream
in interfacejava.util.Collection<E>
- Overrides:
stream
in classCollectionMapper<E,R>
-
parallelStream
public CacheStream<R> parallelStream()
Description copied from interface:CloseableIteratorCollection
This stream should be explicitly closed after it has been used. Failure to do so could cause resources to not be freed properly
- Specified by:
parallelStream
in interfaceCacheCollection<E>
- Specified by:
parallelStream
in interfaceCloseableIteratorCollection<E>
- Specified by:
parallelStream
in interfacejava.util.Collection<E>
- Overrides:
parallelStream
in classCollectionMapper<E,R>
-
-