title: How to produce a list of enum keys/names in groovy
body: <p>I have the following enum in groovy</p>
  
  <pre><code>public enum ImageTypes {
  
      jpg ("image/jpeg"),
      jpeg ("image/jpeg"),
      jpe ("image/jpeg"),
      jfif ("image/jpeg"),
      bmp ("image/bmp"),
      png ("image/png"),
      gif ("image/gif"),
      ief ("image/ief"),
      tiff ("image/tiff"),
      tif ("image/tiff"),
      pcx ("image/pcx"),
      pdf ("application/pdf"),
  
      final String value
  
      ImageTypes(String value) {
          this.value = value
      }
  
      String getValue() {
          return this.value
      }
  
      String toString(){
          value
      }
  
      String getKey() {
          name()
      }
  }
  </code></pre>
  
  <p>and I want to produce an ArrayList&lt;String&gt; of the keys or the values</p>
  
  <p>What I am currently doing is looping through all the items and building the array list, but I'm thinking there has got to be a simple way to do this...</p>
  
  <pre><code>def imageTypes = ImageTypes.values()
  def fileExts = new ArrayList&lt;String&gt;()
  def mimeTypes = new ArrayList&lt;String&gt;()
  for (type in imageTypes) {
      fileExts.add(type.key)
      mimeTypes.add(type.value)
  }
  </code></pre>