Created
December 5, 2022 18:51
-
-
Save dehidehidehi/267205fd151349e0bf25b408f389af4a to your computer and use it in GitHub Desktop.
Custom collector for a LinkedHashMap with values all set to Optional empty.
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
/** | |
* Custom collector for a {@link LinkedHashMap} with values all set to {@link Optional#empty()} | |
*/ | |
private <T, R> Collector<T, ?, LinkedHashMap<T, Optional<R>>> toEmptyLinkedHashMap() { | |
return Collectors.toMap(Function.identity(), f -> Optional.empty(), (x, y) -> y, LinkedHashMap::new); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment