If I want to declare a map of constants, with java 11 I can do this:
Map<String, String> map = Map.of(
key, value,
key, value,
etc. etc
)
For my purpose, I need a LinkedHashMap because I need to keep safe the order in which the key value couples are definied, mainly because I need to stream and find first element in the map.
Something like:
return map.entrySet().stream()
.filter(o -> o.getValue != null))
.findFirst()
.map(Map.Entry::getKey)
Any hints?