Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Groovy Intersect 2对象列表_Groovy - Fatal编程技术网

Groovy Intersect 2对象列表

Groovy Intersect 2对象列表,groovy,Groovy,我正在尝试将两个POGO列表相交 我需要在POGO上实现哪些方法/接口 intersect方法的文档仅说明它必须是Iterable 即 其中列表1和列表2包含POGO。您最安全的赌注是可比的,,最简单的“免费”获取方法是通过AST转换。例如 @groovy.transform.Sortable(includes=['id']) class Pogo { Long id } def n = { new Pogo(id:it) } assert [n(1),n(2)].intersect

我正在尝试将两个POGO列表相交

我需要在POGO上实现哪些方法/接口

intersect方法的文档仅说明它必须是Iterable


其中列表1和列表2包含POGO。

您最安全的赌注是可比的
,最简单的“免费”获取方法是通过AST转换。例如

@groovy.transform.Sortable(includes=['id'])
class Pogo {
    Long id
}

def n = { new Pogo(id:it) }

assert [n(1),n(2)].intersect([n(1)])*.id == [1]

@tim_yates没有为我工作,然后我跟踪了来源,基本上第一件事就是检查Compariable。有趣的是,今晚当我有一台电脑时,我会看看:-)
@groovy.transform.Sortable(includes=['id'])
class Pogo {
    Long id
}

def n = { new Pogo(id:it) }

assert [n(1),n(2)].intersect([n(1)])*.id == [1]