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()} );
}
}