Class NumberCaster
java.lang.Object
ortus.boxlang.runtime.dynamic.casters.NumberCaster
- All Implemented Interfaces:
IBoxCaster
I handle casting anything to a Number, but I will use the "smallest" number type possible
So Integer, Long, Double, BigDecimal
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanIf true, booleans will be treated as numbers, with true=1 and false=0 This is here for compat to toggle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CastAttempt<Number> Tests to see if the value can be cast to a Number.static CastAttempt<Number> Tests to see if the value can be cast to a Number.static NumberUsed to cast anything to a Number, throwing exception if we failstatic NumberUsed to cast anything to a Number, throwing exception if we failstatic NumberUsed to cast anything to a Numberstatic NumberUsed to cast anything to a Number
-
Field Details
-
booleansAreNumbers
public static boolean booleansAreNumbersIf true, booleans will be treated as numbers, with true=1 and false=0 This is here for compat to toggle
-
-
Constructor Details
-
NumberCaster
public NumberCaster()
-
-
Method Details
-
attempt
Tests to see if the value can be cast to a Number. Returns aCastAttempt<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 Number- Returns:
- The Number value
-
attempt
Tests to see if the value can be cast to a Number. Returns aCastAttempt<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 Number- Returns:
- The Number value
-
cast
Used to cast anything to a Number, throwing exception if we fail- Parameters:
object- The value to cast to a Number- Returns:
- The Number value
-
cast
Used to cast anything to a Number, throwing exception if we fail- Parameters:
object- The value to cast to a Number- Returns:
- The Number value
-
cast
Used to cast anything to a Number- Parameters:
object- The value to cast to a Numberfail- If true, throw exception if we fail- Returns:
- The Number value
-
cast
Used to cast anything to a Number- Parameters:
object- The value to cast to a Numberfail- If true, throw exception if we fail- Returns:
- The Number value
-