Created
November 13, 2013 20:38
-
-
Save axiak/7455995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before | |
Optional<Widget> maybeWidget = ... | |
if (maybeWidget.isPresent()) { | |
return maybeWidget.get(); | |
} else { | |
throw new WidgetNotFoundException(widgetId); | |
} | |
// After | |
Optional<Widget> maybeWidget = ... | |
return maybeWidget.orThrow(new WidgetNotFoundException(widgetId)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment