Class ClosureCaster

java.lang.Object
ortus.boxlang.runtime.dynamic.casters.ClosureCaster
All Implemented Interfaces:
IBoxCaster

public class ClosureCaster extends Object implements IBoxCaster
I handle casting anything to a Closure
  • Constructor Details

    • ClosureCaster

      public ClosureCaster()
  • Method Details

    • attempt

      public static CastAttempt<Closure> attempt(Object object)
      Tests to see if the value can be cast to a Function. Returns a CastAttempt<T> which will contain the result if casting was was successfull, or can be interogated to proceed otherwise.
      Parameters:
      object - The value to cast to a Closure
      Returns:
      The Closure value
    • cast

      public static Closure cast(Object object)
      Used to cast anything to a Closure, throwing exception if we fail
      Parameters:
      object - The value to cast to a Closure
      Returns:
      The Closure value
    • cast

      public static Closure cast(Object object, boolean fail)
      Used to cast anything to a Closure
      Parameters:
      object - The value to cast to a Closure
      fail - True to throw exception when failing.
      Returns:
      The Closure value, or null when cannot be cast