|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.util.enum.BaseEnum.EnumTypeAggregator
This inner class of the BaseEnum system catalogs all enumeration instances for one particular class of enumerated values. It holds references by name and by ordinal value to those instances and is accessed through aggregation, by map, in the BaseEnum static methods.
This class should never be referenced outside of the BaseEnum class
as we have given full aggregation control of all enumeration instances
in the system to the BaseEnum type. This has the advantage of requiring
that all instances of a single enum value will actually point at the same
class negating the need for any complex equals
or
hashcode
implementation.
Field Summary | |
private Class |
enumType
A reference to the class type of a BaseEnum subclass |
private Map |
nameMap
A mapping of names to their Enumerated Instances |
private int |
nextOrdinal
The value of the next ordinal to be created in this enumeration |
private SortedMap |
ordinalMap
A mapping of ordinal values to their Enumerated Instances |
Constructor Summary | |
BaseEnum.EnumTypeAggregator(Class enumType)
This constructs a new EnumTypeCatalog that will catalog the types for one specific Class type of BaseEnum. |
Method Summary | |
void |
addEnumeratedInstance(BaseEnum enumeratedType)
Adds a specific instance of an enumerated type to this catalogue for a specific subclass of BaseEnum . |
BaseEnum |
getByName(String name)
Looks up a enumeration instance in this catalogue by name |
BaseEnum |
getByOrdinal(int ordinal)
Looks up a enumeration instance in this catalogue by ordinal |
int |
getNextOrdinal()
Retrieves the next available ordinal value for this aggregate of enumeration instances. |
Iterator |
iterator()
Provides access to an umodifiable iterator over the instances of this enumeration. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private Class enumType
private int nextOrdinal
private Map nameMap
private SortedMap ordinalMap
Constructor Detail |
public BaseEnum.EnumTypeAggregator(Class enumType)
Class
type of BaseEnum.
enumType
- the type of the enumeration being builtMethod Detail |
public Iterator iterator()
public int getNextOrdinal()
public void addEnumeratedInstance(BaseEnum enumeratedType)
BaseEnum
.
enumeratedType
- the enumerated type instance to add to this
cataloguepublic final BaseEnum getByName(String name)
name
- the name of the enumeration instance to lookup
public BaseEnum getByOrdinal(int ordinal)
ordinal
- the ordinal value of the enumeration instance
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |