JDK-6380133 : RFE: LTP: PersistenceDelegate for typesafe enum pattern
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-02-02
  • Updated: 2011-01-19
  • Resolved: 2006-04-18
Related Reports
Duplicate :  
Description
We should provide persistence delegate for enum classes. Also we should think about persistence delegate for classes that implements Typesafe Enum pattern from Effective Java.

Comments
EVALUATION We can use following persistence delegate for all classes that extends Enum: public class EnumDelegate extends PersistenceDelegate { protected boolean mutatesTo( Object oldInstance, Object newInstance ) { return oldInstance == newInstance; } protected Expression instantiate( Object oldInstance, Encoder out ) { Enum e = ( Enum )oldInstance; return new Expression( e, Enum.class, "valueOf", new Object[]{e.getClass(), e.toString()} ); } }
02-02-2006