private Map<String, List<Event>> partitionEventsByInvokeValue(List<Event> events) {
Map<String, List<Event>> partitionedEvents = new HashMap<>();
Map<Integer, String> lastInvokeValueForProcess = new HashMap<>();
for (Event event : events) {
int process = event.process();
if (event instanceof InvokeEvent) {
InvokeEvent invokeEvent = (InvokeEvent) event;
lastInvokeValueForProcess.put(process, invokeEvent.value());
}
String key = lastInvokeValueForProcess.getOrDefault(process, null);
if (event instanceof InfoEvent) {
key = null;
}
List<Event> history = partitionedEvents.getOrDefault(key, new ArrayList<>());
history.add(event);
partitionedEvents.put(key, history);
}
return partitionedEvents;
}