Can you merge multiple ENUM checks in a single check?

0
I've got this code and was wondering if this could be written shorter. $Object/Status = Module.Status.SUBMITTED or $Object/Status = Module.Status.RESUBMITTED or $Object/Status = Module.Status.ACCEPTED or $Object/Status = Module.Status.CONFIRMED It seems a bit redundant to specify the object and attribute each time. It would be pretty nice to write something like $Object/Status = [ Module.Status.SUBMITTED Module.Status.RESUBMITTED Module.Status.ACCEPTED Module.Status.CONFIRMED ] (I feel I've asked this question already, but anyhow.. :) )
asked
3 answers
2

In the Exclusive split, just use $Object/Status. 

This allows you to have separate lines for each ENUM values. 

In my opinion, this is more maintainable solution, because, if you add new ENUM values, Modeller already complains about all places where the new value must be handled. If you write it like how you are writing now, Modeller does not complain. 

But as an direct answer, it is not possible out of box in Mendix. May be you write to write some custom Java action, which could also be an overkill for your requirement. 

answered
0

I agree the enumeration check could be a little more compact.  It especially stands out to those with a programming background.  Unfortunately, without stepping outside the platform and into Java, your idea is currently not possible in Mendix.  The Modeler attempts to walk a fine line between a low barrier to entry and a powerful equation editor, and this is just where things stand today.  I do recommend you make an entry in the Idea forum as Mendix has put a recent emphasis on developer 'delighters' like this.

answered
0

The real problem here is that enum's can't have attributes.

Your four enums values:

	Module.Status.SUBMITTED
	Module.Status.RESUBMITTED
	Module.Status.ACCEPTED
	Module.Status.CONFIRMED

Seem to have something in common. Whatever this common feature is, should have been made explicit in your definition of the enum. If you would have been able to do this, you would only have to check for this attribute in your if statement.

This would make for better maintainability. If you add another enum value, you just have to make sure to set it's attributes correctly, and there would not be any need to change any logic.

 

answered