Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.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到Java的匹配方法_Java_List_Groovy_Static - Fatal编程技术网

找不到从Groovy到Java的匹配方法

找不到从Groovy到Java的匹配方法,java,list,groovy,static,Java,List,Groovy,Static,我在groovy的静态块中调用此函数,如下所示: Groovyc: [Static type checking] - Cannot find matching method io.swagger.client.util.EmUtil#addLobList(java.lang.Object, java.lang.Object). Please check if the declared type is correct and if the method exists. static {

我在groovy的静态块中调用此函数,如下所示:

Groovyc: [Static type checking] - Cannot find matching method io.swagger.client.util.EmUtil#addLobList(java.lang.Object, java.lang.Object). Please check if the declared type is correct and if the method exists.
static {
    Arrays.asList(LOBEnum.values()).forEach {lob -> EmUtil.getInstance().addLobList(lob.name(), lob.getLob())}
    EmUtil.getInstance().setPrefix("CCB_Reference_Data_")
    EmUtil.getInstance().init()
}
这将调用一个java函数,如下所示:

Groovyc: [Static type checking] - Cannot find matching method io.swagger.client.util.EmUtil#addLobList(java.lang.Object, java.lang.Object). Please check if the declared type is correct and if the method exists.
static {
    Arrays.asList(LOBEnum.values()).forEach {lob -> EmUtil.getInstance().addLobList(lob.name(), lob.getLob())}
    EmUtil.getInstance().setPrefix("CCB_Reference_Data_")
    EmUtil.getInstance().init()
}

它看起来像
lob.name()
lob.getLob()
都有一个
对象的返回类型。如果要将这些方法的返回值用作
addLobList
方法的参数,静态类型检查器需要确保它们是
String
实例。您可以使用
(String)
强制转换这些。或者,您可以将这些方法的返回值更改为
String

,这与您的问题有关吗?嗨,杰夫,谢谢你的回复。lob.name()和lob.getLob()的返回类型仅为字符串而不是对象,如下所示:public final String name(){return name;}public String getLob(){return lob;}