How to produce a list of enum keys/names in groovy

ArrayList of keys

ImageTypes.values()*.name()

ArrayList of values

ImageTypes.values()*.value

There are two things to point out here.

1) I'm using the spread operator to call an action on each entry in a collection (although this case it's just an array), that's how the name() and value references are used.

2) I'm calling name() with parenthesis (as a method) because (I believe) it is an implicit attribute on the enum, whereas I'm just using the value attribute directly from the ImageTypes object for the values.

Tags:

Groovy

Enums