Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
public class MyClass{
protected Map instance;
public void setName( String sName ){
this.instance.put("sName",sName);
}
public void setDate(Date date){
this.instance.put("date", date)
}
public Map getInstanceState(){
return Collections.unmodifiableMap(this.instance);
}
}
protected HashMap inst = new HashMap();
/*
* Get the state of the object properties at a specific moment
*
* @return unmodifiable SortedMap (memento of object)
*/
public Map getMemento(){
return Collections.unmodifiableSortedMap( new TreeMap(this.inst) );
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Open in new window