skip to main content
Corticon Server: Integration & Deployment Guide : Preparing Studio files for deployment : Java enumerations
 

Try Corticon Now

Java enumerations

Enumerations are custom Java objects you define and use inside of your Business Objects. They are used to define a preset value set for a particular type.
For simplicity, let's assume that a Java Enumeration has a Name and multiple Labels (or Types). Here is a common example of a Java Enumeration:
public enum Day
{
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY;
}
The Day enumeration has 5 different Labels {Day.MONDAY, Day.TUESDAY, Day.WEDNESDAY, Day.THURSDAY, and Day.FRIDAY}. All of these labels are all considered of type Day. So if a method signature accepts a Day type, it will accept all 5 of these defined labels.
For example:
public class Person
{
private Day iPayDay = null;

public Day getPayDay() {return iPayDay;}
public void setPayDay(Day aValue) {iPayDay = aValue;}
}
Here is an example of a call to the setPayDay(Day) method:
lPerson.setPayDay(Day.MONDAY);
Because Day.MONDAY is of type Day, the setting of the value is complete.
Note: Prior to Version 5.2, business rules could only set basic Data Types into Business Objects. Basic data types included String, Long, long, Integer, int, and Boolean.
Business rule execution can also set your business object's Enumeration values.Corticon performs this by matching Labels in your business object's enumerations with the Custom Data Type (CDT) labels defined in your Vocabulary.
From our example:
Java Enumeration Label Names for enum Day:
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
Now, the Vocabulary must have these same Labels defined in the CDT that is assigned to the attribute.
Figure 300. Vocabulary CDT Labels must match Business Object Enumeration Labels (Types)
Figure 301. Vocabulary Mapper found correct Metadata based on matching enumeration labels
The key to metadata matching is the Labels – as long as your BO enumeration labels match the Vocabulary's CDT Labels, it should work fine. So what happens if the Labels do NOT match?
Extra validation has been added to the Vocabulary to help identify this problem. The example below shows a Label mismatch:
Figure 302. Vocabulary CDT Label / Object Enumeration Label Mismatch
Notice the Vocabulary attribute is flagged with the small orange warning icon (shown in the upper left of the figure above). The associated warning message states:
Java Object Get Method getPayDay return type is an Enumeration and has a mismatch in values between the Enumeration Labels [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY] and Custom Datatype Labels [MONDAYS, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY].