Interface Lazy<T>

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

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

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Thread-safe implementation.
    static final class 
    Non-thread-safe implementation.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static <T> Lazy<T>
    concurrentOf(Supplier<T> supplier)
    Constructs a thread-safe lazy-initialized object
    static <T> Lazy<T>
    of(Supplier<T> supplier)
    Constructs a lazy-initialized object

    Methods inherited from interface java.util.function.Supplier

    get
  • Method Details

    • of

      static <T> Lazy<T> of(@Nonnull 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 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.