public class Vegetable implements Serializable
{
private final int _type;
protected Vegetable ( int type )
{
_type = type;
}
public static final Vegetable unknown = new Vegetable(0);
public static final Vegetable beet = new Vegetable(1);
public static final Vegetable broccoli = new Vegetable(2);
public static final Vegetable carrot = new Vegetable(3);
private static final Vegetable[] vals =
{
unknown, beet, broccoli, carrot
};
private Object readResolve() throws ObjectStreamException
{
return vals[ _type ];
}
}