#87 - Cases by Type
public Map<String, List<Case>> casesByType(List<Case> cases) {
Map<String, List<Case>> result = new Map<String, List<Case>>();
for (Case c : cases) {
if (c.Type != null) {
if (result.containsKey(c.Type)) {
result.get(c.Type).add(c);
}
else {
result.put(c.Type, new List<Case> { c });
}
}
}
return result;
}
1 Kommentar
public static Map<String, List<Case>> casesByType(List<Case> cases) {
Map<String, List<Case>> result = new Map<String, List<Case>>();
for (Case c : cases) {
if (String.isBlank(c.Type)) {
continue;
}
result.put(c.Type, (result.get(c.Type) ?? new List<Case>()));
result.get(c.Type).add(c);
}
return result;
}