001 package org.codehaus.groovy.runtime; 002 003 import java.lang.reflect.Method; 004 import groovy.lang.Closure; 005 006 /** 007 * This class is a general adapter to adapt a closure to any Java interface. 008 * <p> 009 * @author Ben Yu 010 * @author <a href="mailto:blackdrag@gmx.org">Jochen Theodorou</a> 011 * Jul 27, 2006 3:50:51 PM 012 */ 013 public class ConvertedClosure extends ConversionHandler { 014 015 /** 016 * to create a ConvertedClosure object. 017 * @param closure the closure object. 018 */ 019 protected ConvertedClosure(Closure closure) { 020 super(closure); 021 } 022 023 public Object invokeCustom(Object proxy, Method method, Object[] args) 024 throws Throwable { 025 return ((Closure) getDelegate()).call(args); 026 } 027 } 028