(Optional<String> optString)
| 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 + " === "); |