Class Lazy.Actionable<T>

java.lang.Object
net.minecraftforge.gradleutils.shared.Lazy<T>
net.minecraftforge.gradleutils.shared.Lazy.Actionable<T>
Type Parameters:
T - The type of result
All Implemented Interfaces:
Callable<T>, Supplier<T>
Enclosing class:
Lazy<T>

public static final class Lazy.Actionable<T> extends Lazy<T>
Represents a lazily computed value with the ability to optionally work with it using Lazy.ifPresent(Action) and safely mutate it using map(Action).
  • Method Details

    • map

      public void map(Action<? super T> action)

      Queues the given action to run on the value once it has been computed. If the value has already been resolved, the action will be executed instantly.

      This marks this lazy as present, meaning that any usage of Lazy.ifPresent(Action) will resolve the value.

      Parameters:
      action - The action to run
    • isPresent

      public boolean isPresent()
      Checks if this actionable lazy is present. Presence can either mean that the value has already been computed or has been mutated by map(Action).
      Overrides:
      isPresent in class Lazy<T>
      Returns:
      If this actionable lazy is present
    • copy

      public Lazy.Actionable<T> copy()
      Copies this actionable lazy. This can be useful if you need to split off execution paths and have the same object with different mutations at a specific time.
      Returns:
      A new actionable lazy copied from this one
    • get

      public T get()
      Description copied from class: Lazy
      Gets (and resolves if absent) this lazy value.
      Specified by:
      get in interface Supplier<T>
      Overrides:
      get in class Lazy<T>
      Returns:
      The value