Numeric Transformers
Numeric transformers can be used on the source type of Number - Int, Float or Double. Following transformers are available:
addedBy
addedByReturns result of the addition of the source and value. value is considered Double.
Usage:
.addedBy(value)Example usage:
value.addedBy(15.5)Example return:
10to25.5
dividedBy
dividedByReturns result of the division of the source and value. value is considered Double. Note: Division by zero is handled gracefully, produces zero, and doesn't throw an error.
Usage:
.dividedBy(value)Example usage:
value.dividedBy(2.5)Example return:
5to2
multipliedBy
multipliedByReturns result of multiplication of the source and value. value is considered Double.
Usage:
.multipliedBy(value)Example usage:
value.multipliedBy(4)Example return:
2to8
subtractedBy
subtractedByReturns result of subtraction of the source and value. value is considered Double.
Usage:
.subtractedBy(value)Example usage:
value.subtractedBy(2)Example return:
25to23
rounded
roundedReturns the source rounded to specified number of fractions. value must be Int.
Usage:
.rounded(fractions)Example usage:
value.rounded(1)Example return:
1.11to1or1.16to1.2
ceiled
ceiledReturns the next highest Int by rounding up the source if necessary.
Usage:
.ceiled()Example usage:
value.ceiled()Example return:
1.78to2or-3.14to-3
floored
flooredReturns the next lowest Int by rounding up the source if necessary.
Usage:
.floored()Example usage:
value.floored()Example return:
1.78to1or-3.14to-4
absolute
absoluteReturns absolute source
Usage:
.default(value)Example usage:
value.default("Empty")Example return:
` toEmpty`
positive
positiveReturns the source that is either the same if it was >0, or multiplied by -1 if it was <0.
Usage:
.positive()Example usage:
value.positive()Example return:
-1to1or2to -2`
negative
negativeReturns the source that is either the same if it was <0, or multiplied by -1 if it was >0.
Usage:
.negative()Example usage:
value.negative()Example return:
1to-1or-2to-2
formatDate
formatDateReturns formatted date. The source must be Int holding value of standard time interval since 1970 (Unix epoch time).
Usage:
.formatDate(format)Example usage:
value.formatDate("YYYY-MM-DD")Example return:
1587490511to2020-04-21
Last updated
Was this helpful?