Interface LazyValue<T>

  • Type Parameters:
    T - type of the provided object
    All Superinterfaces:
    Supplier<T>

    public interface LazyValue<T>
    extends Supplier<T>
    A typed supplier that wraps another supplier and only retrieves the value on the first request to Supplier.get(), caching the value for all subsequent invocations.

    Helidon implementations obtained through create(java.util.function.Supplier) and create(Object) are guaranteed to be thread safe.

    • Method Detail

      • create

        static <T> LazyValue<T> create​(Supplier<T> supplier)
        Create a lazy value from a supplier.
        Type Parameters:
        T - type of the value
        Parameters:
        supplier - supplier to get the value from
        Returns:
        a lazy value that will obtain the value from supplier on first call to Supplier.get()
      • create

        static <T> LazyValue<T> create​(T value)
        Create a lazy value from a value.
        Type Parameters:
        T - type of the value
        Parameters:
        value - actual value to return
        Returns:
        a lazy value that will always return the value provided
      • isLoaded

        boolean isLoaded()
        Return true if the value is loaded, false if the supplier was not invoked.
        Returns:
        true if the value is loaded