in src/main/software/amazon/event/ruler/JsonRuleCompiler.java [179:222]
private static void parseObjectInsideOrRelationship(final List<Map<String, List<Patterns>>> rules,
final Path path,
final JsonParser parser,
final boolean withQuotes) throws IOException {
boolean fieldsPresent = false;
while (parser.nextToken() != JsonToken.END_OBJECT) {
fieldsPresent = true;
// field name
final String stepName = parser.getCurrentName();
// If it is "$or" primitive, we should bypass the "$or" primitive itself in the path as it is not
// a real step name, it is just used to describe the "$or" relationship among object in the followed Array.
if (stepName.equals(Constants.OR_RELATIONSHIP_KEYWORD)) {
parseIntoOrRelationship(rules, path, parser, withQuotes);
continue;
}
if (Constants.RESERVED_FIELD_NAMES_IN_OR_RELATIONSHIP.contains(stepName)) {
barf(parser, stepName +
" is Ruler reserved fieldName which cannot be used inside "
+ Constants.OR_RELATIONSHIP_KEYWORD + ".");
}
switch (parser.nextToken()) {
case START_OBJECT:
path.push(stepName);
parseObjectInsideOrRelationship(rules, path, parser, withQuotes);
path.pop();
break;
case START_ARRAY:
writeRules(rules, path.extendedName(stepName), parser, withQuotes);
break;
default:
barf(parser, String.format("\"%s\" must be an object or an array", stepName));
}
}
if (!fieldsPresent) {
barf(parser, "Empty objects are not allowed");
}
}