Groovy - Groovy ambiguous method overload
程序员文章站
2022-07-15 13:04:56
...
修改前
if (CollectionUtils.isEmpty(serviceGraph.getCallMap())) {
serviceGraph.setCallMap(new HashMap<String, Integer>())
}
Caused by: javax.script.ScriptException: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.math.BigDecimal#<init>.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class [Map]
[class java.util.Collection]
修改后
if (CollectionUtils.isEmpty(serviceGraph.getCallMap() as Map)) {
serviceGraph.setCallMap(new HashMap<String, Integer>())
}
- Ps:成功!这里涉及到 Groovy 的 as 语法。