Show TOC

Working with an Enumeration TypeLocate this document in the navigation structure

Use

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

Here is a if-then rule:

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. Manually typing every drug type in every rule will 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.

  • Locate the alias Drug Type , and change its return type to All Drug Types

This section describes the tasks you perform with an enumeration type.