What is a Func object?
A Func object represents a function, namely a block of business logic. Users can create new functions by composing smaller functions, or extend from this class to create any custom functions.
A Func object represents a function, namely a block of business logic. Users can create new functions by composing smaller functions, or extend from this class to create any custom functions.
Here is a sample custom function:
class CustomFunc extends Func {
public CustomFunc() {
super(2);
}
public override Object exec(Object arg1, Object arg2) {
// TODO
return null;
}
}
Func f = new CustomFunc();
In the constructor, we may specify the length of the Func by calling super(2)
, or we can skip this to allow a variadic argument function.
There are a few exec
methods from Func that we can override to provide our own implementations.
Extend exec()
if our Func does not accept any argument.
Extend exec(Object)
if our Func accepts one argument.
Extend exec(Object, Object)
if our Func accepts two arguments.
Extend exec(Object, Object, Object)
if our Func accepts three arguments.
Extend execMore(List