You should be able to call any static function of any class using the fully qualified class name of the class and the method name. This should work: ${ java.lang.Math.ceil(...) }
If you want to make that available as ${ ceil(...) } you need to implement a custom function mapper. This is a little bit more complicated but we can give you the pointers
Note that at some point it gets easier to write a Groovy Script or Java Script as input expression
It’s good to know that we can use fully qualified name of the class for this kind of needs. And understand that Groovy/JS could do much powerful job.
Looking from analyst point of view Custom Functions may look little less confusing in some cases. Is there any GitHub example/test case that you can point me to on this please.
@DanielMeyer I just tried this in an output field: ${java.lang.Math.ceil(billing.consumption)}
and it gives a exception: javax.el.PropertyNotFoundException: Cannot resolve identifier ‘java’
It’d be nice to get this working…
Another simple approach is to wrap methods in an object you pass along as variable. It can be accessed like “func.min(billing.amount, 10)” , where “func” is the name of the instance of this class:
public class Functions {
public int min(int a, int b) {
return Math.min(a, b);
}
}
The advantage of this approach or the custom function mapper over the ${java.lang…} approach is that you can limit the diversity of function calls for some all too creative BA’s.