@Override
@SuppressWarnings("unchecked")
public void onObjectRemoved(ObjectRemoved objectRemoved) {
GlobalId id = objectRemoved.getAffectedGlobalId();
Map<String, Object> newObject2 = (new ObjectMapper()).convertValue(
objectRemoved.getAffectedObject().orElse(null),
new TypeReference<Map<String, Object>>() {
});
if (id instanceof ValueObjectId) {
ValueObjectId idV = (ValueObjectId) id;
String[] path = idV.getFragment().split("/");
Map<String, Object> prevO = getPrevious();
for (int n = 0; n < path.length - 1; n++) {
prevO.putIfAbsent(path[n], new HashMap<String, Object>());
prevO = (Map<String, Object>) prevO.get(path[n]);
}
prevO.put(path[path.length - 1], newObject2);
} else {
result.put(KEY_PREVIOUS, newObject2);
}
}