我试图用Groovy (2.1.6)为Fest创建一个闭包匹配器,如下所示:
def matcherLabel = [ isMatching: { JLabel label -> /* do something */ } ] as GenericTypeMatcher<JLabel>GenericTypeMatcher是一个抽象类,只有一个方法可以实现(isMatching ( T ))
但我知道这个错误:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Error casting map to org.fest.swing.core.GenericTypeMatcher, Reason: null
at org.codehaus.groovy.runtime.DefaultGroovyMethods.asType(DefaultGroovyMethods.java:7562)我想做的事有可能吗?
发布于 2013-08-26 21:59:14
您的问题是GenericTypeMatcher类没有默认的零参数构造函数。将映射转换为像ComponentMatcher这样的接口。如果不能使用接口,另一种选择是子类GenericTypeMatcher并提供一个零参数构造函数。
https://stackoverflow.com/questions/18451531
复制相似问题