Class Lazy<T>

  • All Implemented Interfaces:
    Supplier<T>

    public abstract class Lazy<T>
    extends Object
    implements Supplier<T>
    Since:
    7.0
    Author:
    Eugene Petrenko (eugene.petrenko@gmail.com) Date: 20.01.12 12:58
    • Constructor Detail

      • Lazy

        public Lazy()
    • Method Detail

      • createValue

        @Nullable
        protected abstract T createValue()
      • getValue

        public T getValue()
        Returns:
        current value or initializes it if it was not initialized yet
      • get

        public T get()
        Specified by:
        get in interface Supplier<T>
      • getValueIfInitialized

        public T getValueIfInitialized()
        Returns:
        current value but only if it was initialized (i.e. if getValue() was called), otherwise returns null
      • resetValue

        public void resetValue()
      • create

        public static <T> Lazy<T> create​(@NotNull
                                         Supplier<T> supplier)
        Creates a new instance of Lazy object from the provided supplier.
        Type Parameters:
        T -
        Parameters:
        supplier -
        Returns:
        Since:
        2023.11