in src/main/java/org/apache/sling/event/impl/jobs/scheduling/JobSchedulerImpl.java [363:422]
private boolean match(final ScheduledJobInfoImpl job, final Map<String, Object> template) {
if ( template != null ) {
for(final Map.Entry<String, Object> current : template.entrySet()) {
final String key = current.getKey();
final char firstChar = key.length() > 0 ? key.charAt(0) : 0;
final String propName;
final Operation op;
if ( firstChar == '=' ) {
propName = key.substring(1);
op = Operation.EQUALS;
} else if ( firstChar == '<' ) {
final char secondChar = key.length() > 1 ? key.charAt(1) : 0;
if ( secondChar == '=' ) {
op = Operation.LESS_OR_EQUALS;
propName = key.substring(2);
} else {
op = Operation.LESS;
propName = key.substring(1);
}
} else if ( firstChar == '>' ) {
final char secondChar = key.length() > 1 ? key.charAt(1) : 0;
if ( secondChar == '=' ) {
op = Operation.GREATER_OR_EQUALS;
propName = key.substring(2);
} else {
op = Operation.GREATER;
propName = key.substring(1);
}
} else {
propName = key;
op = Operation.EQUALS;
}
final Object value = current.getValue();
if ( op == Operation.EQUALS ) {
if ( !value.equals(job.getJobProperties().get(propName)) ) {
return false;
}
} else {
if ( value instanceof Comparable ) {
@SuppressWarnings({ "unchecked", "rawtypes" })
final int result = ((Comparable)value).compareTo(job.getJobProperties().get(propName));
if ( op == Operation.LESS && result > -1 ) {
return false;
} else if ( op == Operation.LESS_OR_EQUALS && result > 0 ) {
return false;
} else if ( op == Operation.GREATER_OR_EQUALS && result < 0 ) {
return false;
} else if ( op == Operation.GREATER && result < 1 ) {
return false;
}
} else {
// if the value is not comparable we simply don't match
return false;
}
}
}
}
return true;
}