Class LazyValue<T>

java.lang.Object
org.moddingx.libx.util.lazy.LazyValue<T>

public class LazyValue<T> extends Object
A lazy value that is resolved when it is first used.
  • Constructor Details

    • LazyValue

      public LazyValue(@Nonnull Supplier<? extends T> supplier)
      Creates a new lazy value. the supplier will be called once when the value is first retrieved.
  • Method Details

    • wrap

      public static <T> LazyValue<T> wrap(net.minecraft.util.LazyLoadedValue<T> value)
      Wraps a LazyLoadedValue to a lazy value.
    • get

      public T get()
      Gets the value. If not yet resolved, resolves the lazy value.
    • map

      public <U> LazyValue<U> map(Function<T,U> mapper)
      Gets a new lazy value that will hold the value of this lazy value applied to the mapper function. The mapper function will also get called lazy.