If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.
<X> | Type of the exception to be thrown | |
exceptionSupplier | the supplying function that produces an exception to be thrown |
X | if no value is present | |
NullPointerException | if no value is present and the exception
supplying function is null |
@apiNote
A method reference to the exception constructor with an empty argument
list can be used as the supplier. For example,
IllegalStateException::new
Diagram: Optional