Java implementation of undo/redo feature through command and memento patterns