Class AbstractCacheBackedSet<K,V,E>

java.lang.Object
org.infinispan.cache.impl.AbstractCacheBackedSet<K,V,E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, CacheCollection<E>, CacheSet<E>, org.infinispan.commons.util.CloseableIteratorCollection<E>, org.infinispan.commons.util.CloseableIteratorSet<E>
Direct Known Subclasses:
CacheBackedEntrySet, CacheBackedKeySet

public abstract class AbstractCacheBackedSet<K,V,E> extends Object implements CacheSet<E>
Entry or key set backed by a cache.
Since:
13.0
  • Field Details

    • cache

      protected final CacheImpl<K,V> cache
    • lockOwner

      protected final Object lockOwner
    • explicitFlags

      protected final long explicitFlags
  • Constructor Details

    • AbstractCacheBackedSet

      public AbstractCacheBackedSet(CacheImpl<K,V> cache, Object lockOwner, long explicitFlags)
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Collection<K>
      Specified by:
      size in interface Set<K>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<K>
      Specified by:
      isEmpty in interface Set<K>
    • contains

      public abstract boolean contains(Object o)
      Specified by:
      contains in interface Collection<K>
      Specified by:
      contains in interface Set<K>
    • iterator

      public org.infinispan.commons.util.CloseableIterator<E> iterator()
      Specified by:
      iterator in interface org.infinispan.commons.util.CloseableIteratorCollection<K>
      Specified by:
      iterator in interface Collection<K>
      Specified by:
      iterator in interface Iterable<K>
      Specified by:
      iterator in interface Set<K>
    • forEach

      public void forEach(Consumer<? super E> action)
      Specified by:
      forEach in interface Iterable<K>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<K>
      Specified by:
      toArray in interface Set<K>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<K>
      Specified by:
      toArray in interface Set<K>
    • add

      public boolean add(E e)
      Adding new cache entries via a set is not allowed.

      Please use BasicCache.put(Object, Object) etc.

      Specified by:
      add in interface Collection<K>
      Specified by:
      add in interface Set<K>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<K>
      Specified by:
      remove in interface Set<K>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<K>
      Specified by:
      containsAll in interface Set<K>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Adding new cache entries via a set is not allowed.

      Please use BasicCache.put(Object, Object) etc.

      Specified by:
      addAll in interface Collection<K>
      Specified by:
      addAll in interface Set<K>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<K>
      Specified by:
      removeAll in interface Set<K>
    • removeIf

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

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<K>
      Specified by:
      retainAll in interface Set<K>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<K>
      Specified by:
      clear in interface Set<K>
    • spliterator

      public org.infinispan.commons.util.CloseableSpliterator<E> spliterator()
      Specified by:
      spliterator in interface org.infinispan.commons.util.CloseableIteratorCollection<K>
      Specified by:
      spliterator in interface org.infinispan.commons.util.CloseableIteratorSet<K>
      Specified by:
      spliterator in interface Collection<K>
      Specified by:
      spliterator in interface Iterable<K>
      Specified by:
      spliterator in interface Set<K>
    • stream

      public CacheStream<E> stream()
      Specified by:
      stream in interface CacheCollection<K>
      Specified by:
      stream in interface org.infinispan.commons.util.CloseableIteratorCollection<K>
      Specified by:
      stream in interface Collection<K>
    • parallelStream

      public CacheStream<E> parallelStream()
      Specified by:
      parallelStream in interface CacheCollection<K>
      Specified by:
      parallelStream in interface org.infinispan.commons.util.CloseableIteratorCollection<K>
      Specified by:
      parallelStream in interface Collection<K>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • decoratedWriteContextBuilder

      protected ContextBuilder decoratedWriteContextBuilder()
    • entryToKeyFunction

      protected abstract Function<Map.Entry<K,V>,?> entryToKeyFunction()
    • extractKey

      protected abstract Object extractKey(Object e)
      Extract the key from a set element.
    • wrapElement

      protected abstract E wrapElement(E e)
      Wrap the element if needed