Type Safe Enum Version 1.1
STATUS KEY : Specification Design and Architecture Development and Testing Complete
Adds typesafe enums to the Java language
FunctionalityA powerful feature in the .NET, C and C++ languages is the enum type, but it is missing from the Java language. Enums are used to enumerate constants by assigning an integer value to a constant value. However, the C/C++ form of enums does not enforce type safety, is only based on integers and additional information cannot be added to the enum. This component surpases the C++ enum construct by performing at static constant int speed, but with the additional flexibility of adding additional properties to the enumerator. An example would be the suits of a deck of cards, club, spades, hearts, diamonds, additionally with this component an attribute for the color of the suit could be added.
A program used to add up money uses the TypeSafe Enum pattern when referring to the coins. Penny, Nickel, Dime, Quarter have values of 1, 5, 10, 25 respectively. Using this component, the API is simplified and adding additional information such as a diameter function for each coin is possible.
Adobe Acrobat is required to view TopCoder Software specification documentation.