Memento (Chapter 19)
SOLUTION 19.1 | Storing a memento as an object assumes that the application will still be running when the user wants to restore the original object. Reasons that will force you to save a memento to persistent storage follow.
|
SOLUTION 19.2 | Here is an implementation of createMemento() for FactorySimulator:
public List createMemento() { List list = new ArrayList(); Iterator i = machines.iterator(); while (i.hasNext()) { MachineImage mi = (MachineImage) i.next(); list.add(mi.clone()); } return list; } When you write a |
Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.