public class Lazyable<C> extends Object
Represents a mutable element, probably a collection, which can be mutated directly, or lazily using the Action
mechanism.
If the actions are applied to the root mutable element, then it can be evaluated only once. Lazyable allows the actions to be evaluated many times, without modifying the underlying root.
Constructor and Description |
---|
Lazyable(C root,
Function<? super C,? extends C> copier) |
Modifier and Type | Method and Description |
---|---|
void |
addLazyAction(Action<? super C> action)
Adds an action which will act on a copy of the root collection.
|
C |
getResult()
Returns the final result.
|
C |
getRoot()
Returns the root object.
|
static <T> Lazyable<ArrayList<T>> |
ofArrayList()
Returns a Lazyable wrapper around an ArrayList.
|
static <T> Lazyable<List<T>> |
ofList()
Returns a Lazyable wrapper around a list.
|