MCPcopy Create free account
hub / github.com/BruceEckel/OnJava8-Examples / orElseThrow

Method orElseThrow

streams/Optionals.java:26–33  ·  view source on GitHub ↗
(Optional<String> optString)

Source from the content-addressed store, hash-verified

24 optString.orElseGet(() -> "Generated"));
25 }
26 static void orElseThrow(Optional<String> optString) {
27 try {
28 System.out.println(optString.orElseThrow(
29 () -> new Exception("Supplied")));
30 } catch(Exception e) {
31 System.out.println("Caught " + e);
32 }
33 }
34 static void test(String testName,
35 Consumer<Optional<String>> cos) {
36 System.out.println(" === " + testName + " === ");

Callers 1

setTitleMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected