Interface Lazy<T>

Type Parameters:
T - The type of the value
All Superinterfaces:
Supplier<T>
All Known Subinterfaces:
ClearableLazy<T>
All Known Implementing Classes:
ClearableLazy.Concurrent, ClearableLazy.Fast, 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(@NotNull Supplier<T> supplier)
    Constructs a thread-safe lazy-initialized object
    static <T> Lazy<T>
    of(@NotNull 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(@NotNull @NotNull 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(@NotNull @NotNull 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.