Class Lazy<T>
java.lang.Object
net.minecraftforge.gradleutils.shared.Lazy<T>
- Type Parameters:
T- The type of result
- Direct Known Subclasses:
Lazy.Actionable
This is a simple implementation of a
Lazy value, primarily aimed for use in Java code.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a lazily computed value with the ability to optionally work with it usingifPresent(Action)and safely mutate it usingLazy.Actionable.map(Action). -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Lazy.Actionable<T> actionable(groovy.lang.Closure<T> closure) Creates an actionable lazy of the given closure.static <T> Lazy.Actionable<T> actionable(Callable<T> callable) Creates an actionable lazy of the given callable.call()get()Gets (and resolves if absent) this lazy value.final voidRuns the given action on this lazy value if it is present.booleanChecks if this lazy value is present.static <T> Lazy<T> simple(groovy.lang.Closure<T> closure) Creates a simple lazy of the given closure.static <T> Lazy<T> Creates a simple lazy of the given callable.
-
Field Details
-
closure
The closure that will provide the value for this lazy. -
value
-
-
Method Details
-
simple
-
simple
Creates a simple lazy of the given closure.- Type Parameters:
T- The return type of the closure- Parameters:
closure- The callable to use- Returns:
- The lazy value
-
actionable
Creates an actionable lazy of the given callable.- Type Parameters:
T- The return type of the callable- Parameters:
callable- The callable to use- Returns:
- The lazy value
-
actionable
Creates an actionable lazy of the given closure.- Type Parameters:
T- The return type of the closure- Parameters:
closure- The callable to use- Returns:
- The lazy value
-
isPresent
public boolean isPresent()Checks if this lazy value is present. It is not a requirement that the value has to be resolved.
For simple lazies, it is simply a check if the value has been resolved. See
Lazy.Actionable.isPresent()for actionable lazies.- Returns:
- If this lazy is present
-
ifPresent
Runs the given action on this lazy value if it is present.- Parameters:
action- The action to run- See Also:
-
get
-
call
-