Posts

Showing posts from December, 2008

Java Enum relational modelling

As I have blogged about before, the Java Enum is almost perfect . I say almost because of the annoying restriction that its constructor cannot include a relation to itself, due to forward reference limitations when using the Sun compiler. The issue came up again recently when I wanted to model authority roles in Wicket , so I spent a bit more time with the issue and the following is what I've learned. First though, a recap of the original problem. Consider the following attempt at modeling states of a CD player: public class IlligalForwardReference {     enum Player{         PLAYING(Player.PAUSED, Player.STOPPED),         PAUSED(Player.PLAYING, Player.STOPPED),         STOPPED(Player.PLAYING);         private   final EnumSet<Player> transitionStates;         Player( final Play...