in src/main/software/amazon/event/ruler/ByteMachine.java [88:123]
Set<NameStateWithPattern> transitionOn(final String valString) {
// not thread-safe, but this is only used in the scope of this method on one thread
final Set<NameStateWithPattern> transitionTo = new HashSet<>();
// Do CIDR matching if there is at least one IP pattern, then move on to NUMERIC or STRING matching below.
if (hasIP.get() > 0) {
try {
// we'll try both the quoted and unquoted version to help people whose events aren't in JSON
String ipString;
if (valString.startsWith("\"") && valString.endsWith("\"")) {
ipString = CIDR.ipToString(valString.substring(1, valString.length() -1));
} else {
ipString = CIDR.ipToString(valString);
}
doTransitionOn(ipString, transitionTo, TransitionValueType.CIDR);
} catch (IllegalArgumentException e) {
// no-op, couldn't treat this as an IP address
}
}
// Do just one of NUMERIC or STRING matching. Do NUMERIC if machine has numeric patterns and provided value
// is a number. Otherwise, do STRING. We'll still get the correct behavior even if there are both numeric and
// string patterns present as no value can satisfy both a numeric and a string pattern. This is due to string
// patterns starting/ending with a double quotation, where as numeric patterns never do.
if (hasNumeric.get() > 0) {
try {
doTransitionOn(ComparableNumber.generate(valString), transitionTo, TransitionValueType.NUMERIC);
return transitionTo;
} catch (Exception e) {
// no-op, couldn't treat this as a sensible number
}
}
doTransitionOn(valString, transitionTo, TransitionValueType.STRING);
return transitionTo;
}