public T orElseThrow ( final String msg ) { checkNonEmptyString ( msg , "Valid message required" ) ; if ( isPresent ( ) ) { return get ( ) ; } throw new NoSuchElementException ( msg ) ; }
If optional is not empty return it s value if empty throw a NoSuchElementException with message .