Class CacheCollection<T>

  • Type Parameters:
    T - generic for object type to be cahced.
    All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Collection<T>
    Direct Known Subclasses:
    ByteArrayCache, DoubleArrayCache

    public class CacheCollection<T>
    extends java.util.AbstractCollection<T>
    Implements collection of cache-able objects that can be used to store recurring storage container.

    N.B. this implements only the backing cache of adding, removing, etc. elements. The cache object retrieval should be implemented in the derived class. See for example ByteArrayCache.

    Author:
    rstein
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<java.lang.ref.Reference<T>> contents  
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheCollection()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T recoveredObject)  
      protected void cleanup()  
      void clear()  
      boolean contains​(java.lang.Object object)  
      java.util.Iterator<T> iterator()  
      boolean remove​(java.lang.Object o)  
      int size()  
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • contents

        protected final java.util.List<java.lang.ref.Reference<T>> contents
    • Constructor Detail

      • CacheCollection

        public CacheCollection()
    • Method Detail

      • add

        public boolean add​(T recoveredObject)
        Specified by:
        add in interface java.util.Collection<T>
        Overrides:
        add in class java.util.AbstractCollection<T>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T>
        Overrides:
        clear in class java.util.AbstractCollection<T>
      • contains

        public boolean contains​(java.lang.Object object)
        Specified by:
        contains in interface java.util.Collection<T>
        Overrides:
        contains in class java.util.AbstractCollection<T>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in class java.util.AbstractCollection<T>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<T>
        Overrides:
        remove in class java.util.AbstractCollection<T>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<T>
        Specified by:
        size in class java.util.AbstractCollection<T>
      • cleanup

        protected void cleanup()