You can do remove() as follows:
Function<String, Function<String, String>> remove = r -> s -> StringUtils.remove(s, r); Function<String, String> removeCommas = remove.apply(",");
If you prefer a method reference, you can make a general helper method to curry any fixed arity method:
static <T, U, R> Function<T, Function<U, R>> curry(BiFunction<T, U, R> function) { return a -> b -> function.apply(a, b); } // ... Function<String, Function<String, String>> remove = curry(StringUtils::remove);
Note that this helper follows the order of the parameters, so the above function will capture the target line before the delete line. There is no way to reorder the parameters in the method reference, so you will need to choose an order and stick to it.
source share