I have seen BiConsumer, BiPredicate, BiFunction but not BiSupplier or similar. I tried the below code but got an exception saying:
"Multiple non-overriding abstract methods found in BiSupplier".
@FunctionalInterface
public interface BiSupplier<T, R> {
/**
* Gets a first.
*
* @return a first
*/
T getFirst();
/**
* Gets a second.
*
* @return a second
*/
R getSecond();
}
Can some please help me with this.
A
BiSuppliersimply wouldn't make sense. Methods return a value of a single type in Java.So you should simply create a class holding the two values and return that:
And then just use
Supplier<MyValue<T,R>>instead of creating a new functional interface.