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.- See Also:
- API Note:
- This lazy implementation uses Groovy's closures instead of typical suppliers or
callables, as the closure API allows chaining via
Closure.compose(Closure)andClosure.andThen(Closure). They can still be created using callables.
-
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(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> Creates a simple lazy of the given closure.static <T> Lazy<T> Creates a simple lazy of the given callable.
-
Field Details
-
closure
-
value
-
-
Method Details
-
simple
-
simple
-
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
-
get
-
call
-