org.jtwig.util.FunctionValueUtils Maven / Gradle / Ivy
package org.jtwig.util;
import org.jtwig.exceptions.CalculationException;
import org.jtwig.functions.FunctionRequest;
import org.jtwig.value.WrappedCollection;
import org.jtwig.value.convert.Converter;
import java.math.BigDecimal;
import java.util.Collection;
public class FunctionValueUtils {
private static final String NUMBER_TYPE = "number";
private static final String COLLECTION_TYPE = "collection of objects";
public static String getString (FunctionRequest request, int position) {
return request.getEnvironment().getValueEnvironment().getStringConverter().convert(request.get(position));
}
public static BigDecimal getNumber (FunctionRequest request, int position) {
Converter converter = request.getEnvironment().getValueEnvironment().getNumberConverter();
return convert(converter, NUMBER_TYPE, request, position);
}
public static Collection