Class AsyncSupplier<T>

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

    @ThreadSafe
    public final class AsyncSupplier<T>
    extends java.lang.Object
    implements java.util.function.Supplier<java.util.Optional<T>>
    Supplier that will evaluate a delegate supplier asynchronously, returning Optional.empty() until the underlying result is complete, at which point it will be returned. This computation is only initiated after the first call to get, but will be memoized infinitely after that. If the delegate throws, it will not be retried and Optional.empty() will be returned for the lifecycle of this supplier. Note that this class is responsible for creating and shutting down any executors. This class is thread safe by synchronising on get().
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> AsyncSupplier<T> create​(java.util.function.Supplier<java.util.Optional<T>> delegate)  
      java.util.Optional<T> get()  
      • Methods inherited from class java.lang.Object

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

      • get

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

        public static <T> AsyncSupplier<T> create​(java.util.function.Supplier<java.util.Optional<T>> delegate)