org.schmant.lang
Class ClosureSupport

java.lang.Object
  extended by org.schmant.lang.ClosureSupport

public final class ClosureSupport
extends Object

Static utility class for running closures. When Schmant launches, the script language executor registers itself here as a ClosureRunner.

Since:
1.1
Author:
Karl Gustafsson

Method Summary
static boolean isClosure(Object o)
          Is the supplied object a closure? If the running ScriptExecutor does not support closures, this method always returns false.
static void registerClosureRunner(ClosureRunner cr)
           
static Object runClosure(Object closure, Object... arguments)
          Run the closure and return the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerClosureRunner

public static void registerClosureRunner(ClosureRunner cr)

isClosure

public static boolean isClosure(Object o)
Is the supplied object a closure? If the running ScriptExecutor does not support closures, this method always returns false.

Parameters:
o - The object to investigate.
Returns:
true if the supplied object is a closure that the running script executor can run.

runClosure

public static Object runClosure(Object closure,
                                Object... arguments)
Run the closure and return the result.

Parameters:
closure - The closure to run.
arguments - The arguments to the closure.
Returns:
The result returned from the closure.