The documentation of Supplier::get is not explicit on the possibility or not for it to return null. Is it possible ?
I thought that it might be the case of a Supplier<Void>. In this case, how can I invoke my Supplier to make sure it does not result in Supplier<Void> ? In other word, which T is such such that it can be anything but Void ?
As pointed out by @Michael, it most certainly can, as in the following code snippet:
import java.util.function.*;
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Supplier<String> supplier = () -> null;
System.out.println(supplier.get());
}
}
It painfully highlighted my poor understanding of coping with high order usage of Provider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With