An enumeration type allows you to define an abstract type that holds a list of values of the same primitive Java type that are logically related in a given context. An enumeration type is said to have a base type. Here the base type refers to the type of data that this enumeration type can hold.
Example
An if-then rule to determine the price of the drug depending on the drug type is as follows:
If |
|
Drug type equals cancer_drug |
|
Then |
|
Assign price = 500 |
In real world situations, you typically have many drugs and you will have an if-then rule or a decision table row for each drug. If you manually enter each drug type, the whole process is likely to be error prone.
The alternative solution using an enumeration type is:
Define an enumeration type called All Drug Types
Populate this enumeration type with all the drug types such as Cancer_Drug, Vitamin_Drug, Flu_Drug
Locate the alias Drug Type, and change its return type to All Drug Types
This will get reflected in an if-then rule as follows:
If |
|
Drug type equals (all drug type appear in a drop down menu) |
|
Then |
|
Assign price = 500 |