Class Lazyable<C>


  • 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 Detail

      • Lazyable

        public Lazyable​(C root,
                        Function<? super C,​? extends C> copier)
        Parameters:
        root - The original element.
        copier - Copies the type, so the actions can be applied to it.
    • Method Detail

      • getRoot

        public C getRoot()
        Returns the root object.
      • addLazyAction

        public void addLazyAction​(Action<? super C> action)
        Adds an action which will act on a copy of the root collection.
      • getResult

        public C getResult()
        Returns the final result.
      • ofList

        public static <T> Lazyable<List<T>> ofList()
        Returns a Lazyable wrapper around a list.
      • ofArrayList

        public static <T> Lazyable<ArrayList<T>> ofArrayList()
        Returns a Lazyable wrapper around an ArrayList.