public Object evaluate(Object feature) { String value = getExpression(0).evaluate(feature, String.class); if (value == null || value.trim().isEmpty()) { return null; } Unit<Length> defaultUnit = getExpression(1).evaluate(feature, Unit.class); Double scaleFactor = getExpression(2).evaluate(feature, Double.class); if (scaleFactor == null) { throw new IllegalArgumentException("Invalid scale factor, it should be non null"); } RescalingMode mode = RescalingMode.KeepUnits; if (getParameters().size() >= 3) { RescalingMode theMode = getExpression(3).evaluate(feature, RescalingMode.class); if (theMode != null) { mode = theMode; } } // compute the rescaling now that we have all the details Measure measure = new Measure(value, defaultUnit); String result = mode.rescaleToString(scaleFactor, measure); return result; } }