Interface Lazy<T>

  • Type Parameters:
    T - The type of the value
    All Superinterfaces:
    java.util.function.Supplier<T>
    All Known Implementing Classes:
    Lazy.Concurrent, Lazy.Fast

    public interface Lazy<T>
    extends java.util.function.Supplier<T>
    Proxy object for a value that is calculated on first access
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Lazy.Concurrent<T>
      Thread-safe implementation.
      static class  Lazy.Fast<T>
      Non-thread-safe implementation.
    • Method Summary

      Static Methods 
      Modifier and Type Method Description
      static <T> Lazy<T> concurrentOf​(java.util.function.Supplier<T> supplier)
      Constructs a thread-safe lazy-initialized object
      static <T> Lazy<T> of​(java.util.function.Supplier<T> supplier)
      Constructs a lazy-initialized object
      • Methods inherited from interface java.util.function.Supplier

        get
    • Method Detail

      • of

        static <T> Lazy<T> of​(@Nonnull
                              java.util.function.Supplier<T> supplier)
        Constructs a lazy-initialized object
        Parameters:
        supplier - The supplier for the value, to be called the first time the value is needed.
      • concurrentOf

        static <T> Lazy<T> concurrentOf​(@Nonnull
                                        java.util.function.Supplier<T> supplier)
        Constructs a thread-safe lazy-initialized object
        Parameters:
        supplier - The supplier for the value, to be called the first time the value is needed.