You can do this, but you will need to explicitly specify ...
transactions.forEach(((Consumer<Entity>)(entityValidator::validate))
.andThen(getDao()::update));
The fact is that a reference to a method like this entityValidator::validateone is not of type, it is a poly expression, and it depends on the context.
:
@SafeVarargs
private static <T> Consumer<T> combine(Consumer<T>... consumers) {
return Arrays.stream(consumers).reduce(s -> {}, Consumer::andThen);
}
:
transactions.forEach(combine(entityValidator::validate, getDao()::update))