Grails 在groovy中从对象列表中收集值

Grails 在groovy中从对象列表中收集值,grails,groovy,gorm,Grails,Groovy,Gorm,我有一个这样的方法 static getList (long colorid) { ColorShades.findAll 'from ColorShades where color.id = :colorid', [colorid: colorid] } 我是这样使用它的: def shadeIdsForAColor = ColorShades.getList(colorid as long) 问题 该方法返回ColorShade对象的ArrayList,每个对象都有一个shad

我有一个这样的方法

static getList (long colorid) {
     ColorShades.findAll 'from ColorShades where color.id = :colorid', [colorid: colorid]
}
我是这样使用它的:

def shadeIdsForAColor = ColorShades.getList(colorid as long)
问题

该方法返回
ColorShade
对象的
ArrayList
,每个对象都有一个
shadeId

如何将这些ID作为整数列表放入
shadeIdsForAColor
变量中?

这样做不是吗

def shadeIdsForAColor = ColorShades.getList(colorid as long).shadeId

嗯,那确实管用。。所以我可以调用列表上的属性,它们将自动作为列表返回?非常可爱。@Sharma是的,你也可以使用长格式的
ColorShades.getList(colorid为long)*.shadeId
nice,至少在我习惯它之前,它的黑魔法可能会少一些。@Sharma是的,我也更喜欢
*。
格式,原因相同:)