Class Lazy.DoubleCheckedLazy<T>

java.lang.Object
ru.progrm_jarvis.javacommons.lazy.Lazy.DoubleCheckedLazy<T>
Type Parameters:
T - type of wrapped value
All Implemented Interfaces:
Supplier<T>, Lazy<T>
Enclosing interface:
Lazy<T>

public static final class Lazy.DoubleCheckedLazy<T> extends Object implements Lazy<T>
Thread-safe (using double-checked locking) lazy getting its value from the specified value supplier.
  • Method Details

    • get

      public T get()
      Description copied from interface: Lazy
      Gets the wrapped value initializing it once requested.
      Specified by:
      get in interface Lazy<T>
      Specified by:
      get in interface Supplier<T>
      Returns:
      wrapped value
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: Lazy
      Tests if the value of this lazy was initialized.
      Specified by:
      isInitialized in interface Lazy<T>
      Returns:
      true if this lazy's value was initialize and false otherwise
    • getInitializedOrNull

      @Nullable public T getInitializedOrNull()
      Description copied from interface: Lazy
      Gets the wrapped value if it is already initialized or null otherwise.
      Specified by:
      getInitializedOrNull in interface Lazy<T>
      Returns:
      wrapped value if it is already initialized or null otherwise
      See Also:
    • getAsResult

      @NotNull public @NotNull Result<T,Void> getAsResult()
      Description copied from interface: Lazy
      Gets the wrapped value wrapped in Result if it is already initialized or a Result.nullError() otherwise.
      Specified by:
      getAsResult in interface Lazy<T>
      Returns:
      wrapped value wrapped in Result if it is already initialized or Result.nullError() otherwise