Class BooleanCaster

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

public class BooleanCaster extends Object implements IBoxCaster
I handle casting anything to a boolean
  • Constructor Details

    • BooleanCaster

      public BooleanCaster()
  • Method Details

    • attempt

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

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

      public static Boolean cast(Object object, Boolean fail)
      Used to cast anything to a boolean, throwing exception if we fail
      Parameters:
      object - The value to cast to a boolean
      fail - True to throw exception when failing
      Returns:
      The boolean value
    • cast

      public static Boolean cast(Object object, Boolean fail, Boolean loose)
      Used to cast anything to a boolean
      Parameters:
      object - The value to cast to a boolean
      fail - True to throw exception when failing.
      loose - True to allow for truthy and falsey values when casting
      Returns:
      The boolean value, or null when cannot be cast