When a Java method accepts a Function<? super T, ? extends U>
, then it's possible to provide method references in a syntax like the following: MyClass::myMethod
.
However, I'm wondering if there's a way to chain multiple method calls. Here's an example to illustrate the case.
// on a specific object, without lambda
myString.trim().toUpperCase()
I am wondering if there is a syntax to translate this to a lambda expression. I am hoping there is something like the following:
// something like: (which doesn't work)
String::trim::toUpperCase
Alternatively, is there a utility class to merge functions?
// example: (which does not exist)
FunctionUtil.chain(String::trim, String::toUpperCase);