Fork me on GitHub

OperatorUtils

In package com.mitchellbosecke.pebble.utils

public class OperatorUtils extends Object

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.

Constructors

public OperatorUtils()
Parameters:
  • No parameters

Methods

public static Object add(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static Object subtract(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static Object multiply(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static Object divide(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static Object mod(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static boolean equals(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static boolean gt(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static boolean gte(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static boolean lt(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static boolean lte(Object op1, Object op2)
Parameters:
  • Object op1
  • Object op2
public static Object unaryPlus(Object op1)
Parameters:
  • Object op1
public static Object unaryMinus(Object op1)
Parameters:
  • Object op1