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 enumprivate static enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectprivate static ObjectDeprecated.private static BigDecimalbigDecimalOperation(BigDecimal op1, BigDecimal op2, OperatorUtils.Operation operation) private static <T extends Enum<T>>
booleancompareEnum(Enum<T> enumVariable, String compareToString) private static ObjectconcatenateStrings(String op1, String op2) static Objectprivate static booleandoubleComparison(double op1, double op2, OperatorUtils.Comparison comparison) private static doubledoubleOperation(double op1, double op2, OperatorUtils.Operation operation) static booleanprivate static FloatfloatOperation(Float op1, Float op2, OperatorUtils.Operation operation) static booleanstatic booleanprivate static longintegerOperation(int op1, int op2, OperatorUtils.Operation operation) private static longlongOperation(long op1, long op2, OperatorUtils.Operation operation) static booleanstatic booleanstatic Objectstatic Objectstatic Objectprivate static ObjectsubtractFromList(List<?> op1, Object op2) Deprecated.static ObjectunaryMinus(Object op1) static Objectprivate static booleanwideningConversionBinaryComparison(Object op1, Object op2, OperatorUtils.Comparison comparison) private static ObjectwideningConversionBinaryOperation(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
-