I am ashamed that I am stuck on this, but I am trying to get the list of strings ( List<String>) out of the Map<MyEnum, String>then specified List of enum keys List<MyEnum>. List<MyEnum>may or may not contain records.
Edit:
List<String> toReturn = new ArrayList<>();
for (MyEnum field : fields) {
String value = null;
if ((value = map.get(field)) != null) {
toReturn.add(value);
}
}
return toReturn;
But I'm looking for a Java 8 way to do this. Such as...
map.stream().map(e->?????)
source
share