Class DefaultMementoCaretaker

    • Constructor Detail

      • DefaultMementoCaretaker

        public DefaultMementoCaretaker​(TypedMap typedMap)
    • Method Detail

      • restore

        public void restore​(Memento memento)
        Description copied from interface: MementoCaretaker
        Mutates a Memento to match the state of a saved Memento. The Memento parameter is restored from a saved Memento having an ID equal to its ID as returned by Memento.getAnchor(). The Memento parameter remains unchanged if no such saved Memento exists.
        Specified by:
        restore in interface MementoCaretaker
        Parameters:
        memento - the Memento to restore
      • forget

        public void forget​(Memento visitorMemento)
        Description copied from interface: MementoCaretaker
        Removes the Memento having an ID equal to the Memento parameter's ID as returned by Memento.getAnchor().
        Specified by:
        forget in interface MementoCaretaker
        Parameters:
        visitorMemento - the Memento to be removed
      • forget

        public void forget​(Fragment<?> fragment)
        Description copied from interface: MementoCaretaker
        Removes all Mementos bound to the Fragment parameter.
        Specified by:
        forget in interface MementoCaretaker
        Parameters:
        fragment - the fragment
      • stash

        public <T extends Memento> T stash​(T defaultMemento,
                                           Function<T,​T> function)
        Description copied from interface: MementoCaretaker
        Invokes a Consumer with a restored Memento and then saves the Memento. This method offers a convenient way to aggregate and save data instead of writing:
         mementoCaretaker.restore(Memento);
         // add data to memento
         // ...
         mementoCaretaker.save(memento);
         
        Specified by:
        stash in interface MementoCaretaker
        Parameters:
        defaultMemento - the Memento to be restored
        function - the function acting on the restored Memento and returning a new Memento replacing the earlier memento
        See Also:
        MementoCaretaker.restore(Memento), MementoCaretaker.capture(Memento)