I have a Consumer<T>
that I'd like to convert into a Function<T, Void>
.
I could achieve that by using
public <T> Function<T, Void> consumerToFunction(Consumer<T> consumer)
{
return x -> {
consumer.accept(x);
return null;
};
}
But I suspect that something like that might already exist in the JDK or perhaps in a common library.