Many conditions need to be scanned for the first one that matches a set of tests. If there is a matching condition, that conditions ConfigId
should be returned.
I have a way to do the matching of conditions, but there are too many continue
statements. Is there a better way to perform these checks?
private Integer match(List<ConfitionEntity> conditions, ActualDto actualDto) {
if (CollectionUtils.isEmpty(conditions)) {
return null;
}
Integer configId = null;
for (ConfitionEntity condition : conditions) {
boolean match = matchState(condition, actualDto);
if (!match) {
continue;
}
match = matchStatus(condition, actualDto);
if (!match) {
continue;
}
match = matchType(condition, actualDto);
if (!match) {
continue;
}
match = matchPre(condition, actualDto);
if (!match) {
continue;
}
match = matchMobile(condition, actualDto);
if (!match) {
continue;
}
match = matchAge(condition, actualDto);
if (!match) {
continue;
}
match = matchNumber(condition, actualDto);
if (!match) {
continue;
}
match = matchPassed(condition, actualDto);
if (!match) {
continue;
}
match = matchName(condition, actualDto);
if (match) {
configId = condition.getConfigId();
break;
}
}
return configId;
}