01: package org.codehaus.groovy.runtime;
02:
03: import java.lang.reflect.Method;
04: import groovy.lang.Closure;
05:
06: /**
07: * This class is a general adapter to adapt a closure to any Java interface.
08: * <p>
09: * @author Ben Yu
10: * @author <a href="mailto:blackdrag@gmx.org">Jochen Theodorou</a>
11: * Jul 27, 2006 3:50:51 PM
12: */
13: public class ConvertedClosure extends ConversionHandler {
14:
15: /**
16: * to create a ConvertedClosure object.
17: * @param closure the closure object.
18: */
19: protected ConvertedClosure(Closure closure) {
20: super (closure);
21: }
22:
23: public Object invokeCustom(Object proxy, Method method,
24: Object[] args) throws Throwable {
25: return ((Closure) getDelegate()).call(args);
26: }
27: }
|