本文整理汇总了Java中org.codehaus.groovy.runtime.ConvertedClosure类的典型用法代码示例。如果您正苦于以下问题:Java ConvertedClosure类的具体用法?Java ConvertedClosure怎么用?Java ConvertedClosure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConvertedClosure类属于org.codehaus.groovy.runtime包,在下文中一共展示了ConvertedClosure类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: coerceToSAM
import org.codehaus.groovy.runtime.ConvertedClosure; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Object coerceToSAM(Closure argument, Method method, Class clazz, boolean isInterface) {
if (argument!=null && clazz.isAssignableFrom(argument.getClass())) {
return argument;
}
if (isInterface) {
if (Traits.isTrait(clazz)) {
Map<String,Closure> impl = Collections.singletonMap(
method.getName(),
argument
);
return ProxyGenerator.INSTANCE.instantiateAggregate(impl,Collections.singletonList(clazz));
}
return Proxy.newProxyInstance(
clazz.getClassLoader(),
new Class[]{clazz},
new ConvertedClosure(argument));
} else {
Map<String, Object> m = new HashMap<String,Object>();
m.put(method.getName(), argument);
return ProxyGenerator.INSTANCE.
instantiateAggregateFromBaseClass(m, clazz);
}
}
示例2: getObject
import org.codehaus.groovy.runtime.ConvertedClosure; //导入依赖的package包/类
public InvocationHandler getObject(final String command) throws Exception {
final ConvertedClosure closure = new ConvertedClosure(new MethodClosure(command, "execute"), "entrySet");
final Map map = Gadgets.createProxy(closure, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(map);
return handler;
}
示例3: getObject
import org.codehaus.groovy.runtime.ConvertedClosure; //导入依赖的package包/类
public InvocationHandler getObject(CmdExecuteHelper cmdHelper) throws Exception {
final ConvertedClosure closure = new ConvertedClosure(new MethodClosure(cmdHelper.getCommand(), "execute"), "entrySet");
final Map map = Gadgets.createProxy(closure, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(map);
return handler;
}
示例4: getObject
import org.codehaus.groovy.runtime.ConvertedClosure; //导入依赖的package包/类
public InvocationHandler getObject(final String command) throws Exception {
final ConvertedClosure closure = new ConvertedClosure(new MethodClosure(command, "execute"), "entrySet");
final Map map = Gadgets.createProxy(closure, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(map);
return handler;
}
示例5: getObject
import org.codehaus.groovy.runtime.ConvertedClosure; //导入依赖的package包/类
public InvocationHandler getObject(final String command) throws Exception {
final ConvertedClosure closure = new ConvertedClosure(new MethodClosure(command, "execute"), "entrySet");
final Map map = Gadgets.createProxy(closure, Map.class);
final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(map);
return handler;
}