Such as in .Net, which provides several implementations of the Action
delegate (equivalent to Java Consumer
functional interface) with different number and type of arguments, I was expecting that Java 8 provides some way of specifying a Consumer
with more than one argument of different types.
I know that in Java we cannot define different types with the same name that just differ in the generic type parameters, but there would be nice fluent alternatives to provide a multi-argument Consumer
.
Is there any easy way to do it, which does not require defining a new functional interface?
BiConsumer<T, U>
and variations of it involving primitive types (likeObjIntConsumer<T>
), but no more – FromentyConsumer
/Producer
/Function
/etc. classes along with all of the streaming feature are severely lacking when compared to the C# counterparts. I really wish these features were more complete and seamless. – Chavarria