@@ -0,0 +1,1022 @@
+// --------------------- %E5%A4%87%E5%BF%98%E5%BD%95%E8%A7%92%E8%89%B2%0A%0Apublic class Originator %7B%0A    private String state;%0A%0A    public String getState() %7B%0A        return state;%0A    %7D%0A%0A    public void setState(String state) %7B%0A        this.state = state;%0A    %7D%0A%0A    public Memento createMemento() %7B%0A        return new Memento(state);%0A    %7D%0A%0A    public void restoreMemento(Memento memento) %7B%0A        setState(memento.getState());%0A    %7D%0A%7D%0A%0A// --------------------- %E5%8F%91%E8%B5%B7%E4%BA%BA%E8%A7%92%E8%89%B2%0A%0Apublic class Memento %7B%0A    private String state = %22%22;%0A%0A    public Memento(String state) %7B%0A        this.state = state;%0A    %7D%0A%0A    public String getState() %7B%0A        return state;%0A    %7D%0A%0A    public void setState(String state) %7B%0A        this.state = state;%0A    %7D%0A%7D%0A%0A// --------------------- test code%0A%0Apublic static void main(String%5B%5D args) %7B%0A    Originator originator = new Originator();%0A%0A    originator.setState(%22luoxn28%22);%0A%0A    Memento memento = originator.createMemento();%0A%0A    originator.setState(%22%22);%0A    originator.restoreMemento(memento);%0A%0A    System.out.println(originator.getState());%0A%7D

add memento pattern