public static Set<Event> compareAndExtractEvents(String pre, String post, String ids) throws JSONException, IllegalArgumentException {
        Object preObject = null, postObject = null, idsObject = null;
        if (pre != null) {
            preObject = JSONParser.parseJSON(pre);
        }
        if (post != null && ids != null) {
            postObject = JSONParser.parseJSON(post);
            idsObject = JSONParser.parseJSON(ids);
        } else {
            throw new IllegalArgumentException("post state and projected ids cannot be null:: " + getErrorSignature(pre, post, ids));
        }

        if (!(preObject == null || preObject.getClass().equals(postObject.getClass())) || !postObject.getClass().equals(idsObject.getClass())) {
            throw new IllegalArgumentException("pre state (optional), post state and projected ids need to be valid JSON of the same type:: "
                    + getErrorSignature(pre, post, ids));
        }
        // JSONParser only returns JSONArray/ JSONObject/ JSONString
        if (!postObject.getClass().equals(JSONArray.class) && !postObject.getClass().equals(JSONObject.class)) {
            throw new IllegalArgumentException("Identities can only extracted from JSONArrays or JSONObjects:: " + getErrorSignature(pre, post, ids));
        }

        return compareAndGetEvents(preObject, postObject, idsObject);
    }
public static Set < Event > compareAndExtractEvents ( String pre , String post , String ids ) throws JSONException , IllegalArgumentException { Object preObject = null , postObject = null , idsObject = null ; if ( pre != null ) { preObject = JSONParser . parseJSON ( pre ) ; } if ( post != null && ids != null ) { postObject = JSONParser . parseJSON ( post ) ; idsObject = JSONParser . parseJSON ( ids ) ; } else { throw new IllegalArgumentException ( "post state and projected ids cannot be null:: " + getErrorSignature ( pre , post , ids ) ) ; } if ( ! ( preObject == null || preObject . getClass ( ) . equals ( postObject . getClass ( ) ) ) || ! postObject . getClass ( ) . equals ( idsObject . getClass ( ) ) ) { throw new IllegalArgumentException ( "pre state (optional), post state and projected ids need to be valid JSON of the same type:: " + getErrorSignature ( pre , post , ids ) ) ; } if ( ! postObject . getClass ( ) . equals ( JSONArray . class ) && ! postObject . getClass ( ) . equals ( JSONObject . class ) ) { throw new IllegalArgumentException ( "Identities can only extracted from JSONArrays or JSONObjects:: " + getErrorSignature ( pre , post , ids ) ) ; } return compareAndGetEvents ( preObject , postObject , idsObject ) ; }
/*
Accepts JSONObject / JSONArray and returns the Events for the required
permutations.

NOTE: this doesn't check if the objects are actually different, call this
only if an event is to be created for sure, just to find out what events
are to be created.