Created
March 10, 2015 19:28
-
-
Save rscarvalho/5789ff105c5ffc4aee8d 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
| public MyEnum getEnumObject() { | |
| final List<String> enumStrings = new ArrayList<>(); | |
| enumStrings.add(null); | |
| enumStrings.add("A"); | |
| enumStrings.add("C"); | |
| enumStrings.add("B"); | |
| enumStrings.add("D"); | |
| Optional<MyEnum> e = enumStrings.stream() | |
| .filter(s -> s != null) | |
| .map(MyEnum::valueOf) | |
| .findFirst(); | |
| return e.orElseThrow(IllegalStateException::new); | |
| } |
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
| public enum MyEnum { | |
| A, B, C, D, E | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment