@Override
public boolean match(WrappedBooking wrappedBooking) {
switch (rule.getSimilarityMatchType()) {
case IBAN:
return StringUtils.equalsIgnoreCase(rule.getExpression(), wrappedBooking.getBankConnection());
case REFERENCE_NAME:
if (wrappedBooking.getReferenceName() != null) {
Double result = JARO_WINKLER.apply(rule.getExpression(), wrappedBooking.getReferenceName().toLowerCase());
if (result >= MIN_DISTANCE) {
log.debug("similarity expression {} compared with {} resulted in score {}", rule.getExpression(), wrappedBooking.getReferenceName().toLowerCase(), result);
}
return result >= MIN_DISTANCE;
}
return false;
case PURPOSE:
Double result = JARO_WINKLER.apply(rule.getExpression(), normalize(wrappedBooking.getPurpose()));
if (result >= MIN_DISTANCE) {
log.debug("similarity expression {} compared with {} resulted in score {}", rule.getExpression(), normalize(wrappedBooking.getPurpose()), result);
}
return result >= MIN_DISTANCE;
}
throw new IllegalArgumentException("missing match type");
}