Working with enumerations is actually not too different from how they were used before they were introduced with Java 5:
public final class Suit { public static final Suit CLUBS = new Suit(); public static final Suit DIAMONDS = new Suit(); public static final Suit HEARTS = new Suit(); public static final Suit SPADES = new Suit(); private Suit() {
By creating instances of various stripes when loading classes, it is ensured that they are mutually exclusive, and the private constructor ensures that no additional instances are created.
They would be comparable either through == or equal.
Java 5 interception works in much the same way, but with some necessary features to support serialization, etc.
I hope this background sheds some extra light.
Alex VI Jul 13 '10 at 0:44 2010-07-13 00:44
source share