Package io.pebbletemplates.pebble.utils
Class OperatorUtils
java.lang.Object
io.pebbletemplates.pebble.utils.OperatorUtils
This class acts as a sort of wrapper around Java's built in operators. This is necessary because
Pebble treats all user provided variables as Objects even if they were originally primitives.
It's important that this class mimics the natural type conversion that Java will apply when performing operators. This can be found in section 5.6.2 of the Java 7 spec, under Binary Numeric Promotion.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
private static enum
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
private static Object
Deprecated.private static BigDecimal
bigDecimalOperation
(BigDecimal op1, BigDecimal op2, OperatorUtils.Operation operation) private static <T extends Enum<T>>
booleancompareEnum
(Enum<T> enumVariable, String compareToString) private static Object
concatenateStrings
(String op1, String op2) static Object
private static boolean
doubleComparison
(double op1, double op2, OperatorUtils.Comparison comparison) private static double
doubleOperation
(double op1, double op2, OperatorUtils.Operation operation) static boolean
private static Float
floatOperation
(Float op1, Float op2, OperatorUtils.Operation operation) static boolean
static boolean
private static long
integerOperation
(int op1, int op2, OperatorUtils.Operation operation) private static long
longOperation
(long op1, long op2, OperatorUtils.Operation operation) static boolean
static boolean
static Object
static Object
static Object
private static Object
subtractFromList
(List<?> op1, Object op2) Deprecated.static Object
unaryMinus
(Object op1) static Object
private static boolean
wideningConversionBinaryComparison
(Object op1, Object op2, OperatorUtils.Comparison comparison) private static Object
wideningConversionBinaryOperation
(Object op1, Object op2, OperatorUtils.Operation operation)
-
Constructor Details
-
OperatorUtils
public OperatorUtils()
-
-
Method Details
-
add
-
subtract
-
multiply
-
divide
-
mod
-
equals
-
compareEnum
-
gt
-
gte
-
lt
-
lte
-
unaryPlus
-
unaryMinus
-
concatenateStrings
-
addToList
Deprecated.This is not a documented feature but we are leaving this in for now. I'm unsure if there is demand for this feature. -
subtractFromList
Deprecated.This is not a documented feature but we are leaving this in for now. I'm unsure if there is demand for this feature. -
wideningConversionBinaryOperation
private static Object wideningConversionBinaryOperation(Object op1, Object op2, OperatorUtils.Operation operation) -
wideningConversionBinaryComparison
private static boolean wideningConversionBinaryComparison(Object op1, Object op2, OperatorUtils.Comparison comparison) -
doubleOperation
-
doubleComparison
private static boolean doubleComparison(double op1, double op2, OperatorUtils.Comparison comparison) -
bigDecimalOperation
private static BigDecimal bigDecimalOperation(BigDecimal op1, BigDecimal op2, OperatorUtils.Operation operation) -
floatOperation
-
longOperation
-
integerOperation
-