public Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets( Collection<ProcessInstanceDAO> instances) { Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long, Collection<CorrelationSetDAO>>(); for (ProcessInstanceDAO instance : instances) { Long id = instance.getInstanceId(); Collection<CorrelationSetDAO> existing = map.get(id); if (existing == null) { existing = new ArrayList<CorrelationSetDAO>(); map.put(id, existing); } existing.addAll(instance.getCorrelationSets()); } return map; }