Class DefaultExecutionStrategy

java.lang.Object
ch.obermuhlner.scriptengine.java.execution.DefaultExecutionStrategy
All Implemented Interfaces:
ExecutionStrategy

public class DefaultExecutionStrategy extends Object implements ExecutionStrategy
The default ExecutionStrategy implementation.
  • class implements `Supplier`: the `get()` method is called
  • class implements `Runnable`: the `run()` method is called
  • class has exactly one public method without arguments: call it
  • Field Details

    • clazz

      private final Class<?> clazz
    • method

      private final Method method
  • Constructor Details

  • Method Details

    • execute

      public Object execute(Object instance) throws ScriptException
      Description copied from interface: ExecutionStrategy
      Executes a method on an object instance, or a static method if the specified instance is null.
      Specified by:
      execute in interface ExecutionStrategy
      Parameters:
      instance - the object instance to be executed or null to execute a static method
      Returns:
      the return value of the method, or null
      Throws:
      ScriptException - if no method to execute was found
    • findCallableMethod

      private static Method findCallableMethod(Class<?> clazz)