Class FunctionCaster

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

public class FunctionCaster extends Object implements IBoxCaster
I handle casting anything to a Function
  • Constructor Details

    • FunctionCaster

      public FunctionCaster()
  • Method Details

    • attempt

      public static CastAttempt<Function> 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 Function
      Returns:
      The Function value
    • attempt

      public static CastAttempt<Function> attempt(Object object, String SAMClass)
      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 Function
      Returns:
      The Function value
    • cast

      public static Function cast(Object object, String SAMClass)
      Used to cast anything to a Function, throwing exception if we fail
      Parameters:
      object - The value to cast to a Function
      SAMClass - The name of the SAM class the object is valid to cast to
      Returns:
      The Function value
    • cast

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

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

      public static Function cast(Object object, String SAMClass, boolean fail)
      Used to cast anything to a Function
      Parameters:
      object - The value to cast to a Function
      SAMClass - The name of the SAM class the object is valid to cast to
      fail - True to throw exception when failing.
      Returns:
      The Function value, or null when cannot be cast
    • getSAMName

      public static String getSAMName(Object object, String SAMClass)
      I detect if an instance implements a known FI or a SAM and return the name of the method, null if not a SAM.
      Parameters:
      object - The object to check
      Returns:
      The name of the SAM method, or null if not a SAM