Created
January 3, 2019 16:01
-
-
Save scottashipp/03c2c9aeae14b6003c6047a006472cac to your computer and use it in GitHub Desktop.
Snippet from a popular open-source Java tool showing Optional.isPresent() checking in place of null-checking
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
Optional<String> pathsStr = get(PATHS_KEY); | |
if (pathsStr.isPresent()) { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
try { | |
String[] paths = objectMapper.readValue(pathsStr.get(), String[].class); | |
// ... the rest elided |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment