我在groovy中有以下枚举
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()
    }
}
我想生成键或值的ArrayList <String>
我目前正在做的是循环遍历所有项目并构建数组列表,但我认为必须有一个简单的方法来做到这一点......
def imageTypes = ImageTypes.values()
def fileExts = new ArrayList<String>()
def mimeTypes = new ArrayList<String>()
for (type in imageTypes) {
    fileExts.add(type.key)
    mimeTypes.add(type.value)
}
由于Grails和Groovy中,单引号字符串是从GString的(双引号字符串允许$ {变量}值注射)不同的类,它是更有效的使用单引号,当正在使用的$ {变量}除?我猜测双引号的存在将需要解析普通的单引号字符串不需要的字符串.因此,我希望从寻找$ {}的额外时间中获得非常轻微的性能影响.
因此,除非使用双引号具有特定优势,否则通常有一个鼓励使用单引号的约定似乎是有益的.我是不是基地?