The core BaseEnum
provides a base class implementation of
enumerated types with a type-safe interface. The base class acts as a static
singleton to aggregate all enumerations in the system and ensure that there
is only a single set of instances of each enumerated type. This design feature
simplifies the use of enumerated types and makes them quick and easy to use.
The BaseEnum
has two constructors with no default constructor. In
this manner and subclass of BaseEnum
must call super passing in
an appropriate set of information. The design is such that during the
construction of a particular instance of an Enumerated Type, it will be added
to the system-wide EnumTypeCatalogue
for that type. This ensures
that there is only a single set of types and simplifies the storage and
retrieval by providing lookup and iterator methods in the base class.
Each subclass of enumeration, properly implemented, can provide for
serialization support by appropriately implementing the readResolve
method as in the template and examples. This provides that even during
deserialization, only a single instance of one value of an enumerated type will
exist in the system.
The BaseEnum
constructors provide two mechanisms to create new
enumerated type instances. In the first, the ordinal or numeric value of an
enumeration is automatically determined during construction. This is done in
such a manner as to create consecutive ordinals with the first starting at "0".
The second way is to pass the desired ordinal into the constructor and have it
manually set.
Note: Mixing automatically and manually set ordinals on a single type
can and will result in unusable enuemerations. This should never be done.