public static <T> T required(final Optional<T> optional) {
        notNull(optional);
        isTrue(optional.isPresent(), "No value present");

        return optional.get();
    }
public static < T > T required ( final Optional < T > optional ) { notNull ( optional ) ; isTrue ( optional . isPresent ( ) , "No value present" ) ; return optional . get ( ) ; }
Gets the value of an optional, throwing an exception if no value is present. This can be more convenient than using {@link Optional#orElseThrow(Supplier)}. <p>E.g. instead of doing:
<pre>
final Optional&lt;Integer&gt; opt = Optional.of(1);
final Integer value = opt.orElseThrow(() -&gt; new IllegalArgumentException());
</pre>
we can do:
<pre>
final Optional&lt;Integer&gt; opt = Optional.of(1);
final Integer value = Optionals.required(opt);
</pre>
Another example is ot insert informative exceptions on missing values in a stream:
<pre>
final Stream&lt;Optional&lt;T&gt;&gt; optStream = ...;
final Stream&lt;T&gt; stream = optStream.map(t -&gt; Optionals.required(t));
</pre>

@param optional
the optional to get the value from
@param <T>
the type of the value

@return the value of the optional

@throws IllegalArgumentValidationException
if no value is present