I have written this lambda that is getting values from a map <Code, Message>
contained inside an enum MessageKeyRegistry
and creating adding to another map with Code as the key and the MessageKeyRegistry
as the value.
Map<MessageKey, MessageKeyRegistry> keyMap = new HashMap<>();
EnumSet.allOf(MessageKeyRegistry.class)
.forEach(messageKeyRegistry -> messageKeyRegistry.getCodeToMessage().keySet()
.forEach(code -> keyMap.put(code, messageKeyRegistry)));
Now I want to satisfy the immutability concept of functional programming and write a lambda that returns an immutable map directly.
Please login or Register to submit your answer