liqp.filters.Times Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liqp Show documentation
Show all versions of liqp Show documentation
A Java implementation of the Liquid templating engine backed up by an ANTLR grammar.
The newest version!
package liqp.filters;
import java.math.BigDecimal;
public class Times extends Filter {
/*
* times(input, operand)
*
* multiplication
*/
@Override
public Object apply(Object value, Object... params) {
if(value == null) {
value = 0L;
}
super.checkParams(params, 1);
Object rhsObj = params[0];
if (super.canBeInteger(value) && super.canBeInteger(rhsObj)) {
return super.asNumber(value).longValue() * super.asNumber(rhsObj).longValue();
}
BigDecimal first = new BigDecimal(super.asNumber(value).toString());
BigDecimal second = new BigDecimal(super.asNumber(rhsObj).toString());
return first.multiply(second);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy