code: public static Set<Event> compareAndGetEvents(JSONArray pre, JSONArray post, JSONArray ids) throws JSONException {
          Set<Event> result = new HashSet<>();
          Map<JSONWrapper, JSONWrapper> preMap = getJSONComparisionMap(ids, pre);
          Map<JSONWrapper, JSONWrapper> postMap = getJSONComparisionMap(ids, post);
          for (JSONWrapper key : postMap.keySet()) {
              if (!preMap.containsKey(key) || !preMap.get(key).equals(postMap.get(key))) {
                  Object preJsonObject = (preMap.get(key) == null) ? null : preMap.get(key).getValue();
                  Set<Event> arrayChildResults = compareAndGetEvents(preJsonObject, postMap.get(key).getValue(), key.getValue());
                  for (Event arrayChildResult : arrayChildResults) {
                      if (!preMap.containsKey(key)) {
                          arrayChildResult.setOperation(Operation.INSERT);
                      }
                      result.add(arrayChildResult);
                  }
              }
          }
          return result;
      }
docs: /*
  we cannot assume order of objects in the array are going to remain the
  same, however, we can assume the objects in the array are unique in they
  identifying field values.
  
  identity object is the subset of the integrated state of the entity.
  using that property we create a map for both pre and post arrays, with
  the identifying sub state as the key.
  
  then for all array elements in the identifying array we lookup if that
  element was added or updated.