/** * Returns true if the decider returns true for the given value and the given constraint. This * method handles Mongo's logic where an item can match either an item itself, or any item within * the item, if the item is an array. */ private static boolean compare(Object constraint, Object value, Decider decider) { if (value instanceof List) { return compareList(constraint, (List<?>) value, decider); } else if (value instanceof JSONArray) { return compareArray(constraint, (JSONArray) value, decider); } else { return decider.decide(constraint, value); } }