Number of elements in an Enumeration

2
Is there a way to determine how many elements there are in a enumeration ?
asked
2 answers
1

You could do this in a Java action. Can you explain your case though? Since you define the enumerations yourself, why do you need a count?

If you know Java you can start here: https://world.mendix.com/display/refguide3/Java+Programming and follow the Java API tutorial and read the java doc to figure out the object structure.

answered
4

Create a Java Action (for example EnumCount) with your enumeration (MyEnum) as input and output integer/long. Run the model once. Open the created javafile EnumCount.Java and look for

// BEGIN USER CODE
return 0;
// END USER CODE

Replace with

// BEGIN USER CODE
return (long) MyEnum.values().length;
// END USER CODE

You have to make one per enumeration.

answered