Class PredicateMemoizingSupplier<T>

  • All Implemented Interfaces:
    Memoize<T>, java.util.function.Supplier<T>

    class PredicateMemoizingSupplier<T>
    extends java.lang.Object
    implements Memoize<T>
    The object can exist in one of two states:
    • initial which means the source supplier has not been called or has not returned a value acceptable to the predicate and memoized holds the wrapped supplier. From this state, the object can transition to open.
    • open which means memoized is the value from the source supplier. This is the terminal state.
    Since:
    1.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean initial  
      private java.lang.Object memoized  
    • Constructor Summary

      Constructors 
      Constructor Description
      PredicateMemoizingSupplier​(java.util.function.Supplier<? extends T> supplier, java.util.function.Predicate<? super T> predicate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()  
      T peek()
      Peek the memoized value, if any.
      • Methods inherited from class java.lang.Object

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

      • initial

        private volatile boolean initial
      • memoized

        private java.lang.Object memoized
    • Constructor Detail

      • PredicateMemoizingSupplier

        PredicateMemoizingSupplier​(java.util.function.Supplier<? extends T> supplier,
                                   java.util.function.Predicate<? super T> predicate)
    • Method Detail

      • get

        public T get()
        Specified by:
        get in interface java.util.function.Supplier<T>
      • peek

        public T peek()
        Description copied from interface: Memoize
        Peek the memoized value, if any.

        This method will not result in a call to the source supplier.

        Specified by:
        peek in interface Memoize<T>
        Returns:
        The value if a value is memoized; otherwise null.