View Javadoc

1   package org.codehaus.groovy.runtime;
2   
3   import java.lang.reflect.Method;
4   import groovy.lang.Closure;
5   
6   /***
7    * This class is a general adapter to adapt a closure to any Java interface.
8    * <p>
9    * @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, Object[] args)
24      throws Throwable {
25          return ((Closure) getDelegate()).call(args);
26      }
27  }
28