Class CellPool<T,​C extends Cell<T,​?>>


  • final class CellPool<T,​C extends Cell<T,​?>>
    extends java.lang.Object
    Helper class that stores a pool of reusable cells that can be updated via Cell.updateItem(Object) or creates new ones via its cellFactory if the pool is empty.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.function.Function<? super T,​? extends C> cellFactory  
      private java.util.Queue<C> pool  
    • Constructor Summary

      Constructors 
      Constructor Description
      CellPool​(java.util.function.Function<? super T,​? extends C> cellFactory)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void acceptCell​(C cell)
      Adds the cell to the pool of reusable cells if Cell.isReusable() is true, or disposes the cell if it's not.
      void dispose()
      Disposes the cell pool and prevents any memory leaks.
      C getCell​(T item)
      Returns a reusable cell that has been updated with the current item if the pool has one, or returns a newly-created one via its cellFactory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cellFactory

        private final java.util.function.Function<? super T,​? extends C extends Cell<T,​?>> cellFactory
      • pool

        private final java.util.Queue<C extends Cell<T,​?>> pool
    • Constructor Detail

      • CellPool

        public CellPool​(java.util.function.Function<? super T,​? extends C> cellFactory)
    • Method Detail

      • getCell

        public C getCell​(T item)
        Returns a reusable cell that has been updated with the current item if the pool has one, or returns a newly-created one via its cellFactory.
      • acceptCell

        public void acceptCell​(C cell)
        Adds the cell to the pool of reusable cells if Cell.isReusable() is true, or disposes the cell if it's not.
      • dispose

        public void dispose()
        Disposes the cell pool and prevents any memory leaks.