Created
March 24, 2017 07:47
-
-
Save jonas-grgt/4f2cd0592ab18399358dbbd8eeeb160d to your computer and use it in GitHub Desktop.
This file contains 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
public static <T> Optional<T> resolve(Supplier<T> resolver) { | |
try { | |
T result = resolver.get(); | |
return Optional.ofNullable(result); | |
} catch (NullPointerException e) { | |
return Optional.empty(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment