switch (with.field) {
case "name":
result.stream()
.filter(d -> {
Donor donor = (Donor) d;
if (with.operator == Operator.GREATER_THAN) {
return (0 > donor.getName().compareTo(with.constant));
} else if (with.operator == Operator.LESS_THAN) {
return (0 < donor.getName().compareTo(with.constant));
} else {
return (0 == donor.getName().compareTo(with.constant));
}
});
break;
case "amount":
result.stream()
.filter(d -> {
Donor donor = (Donor) d;
if (with.operator == Operator.GREATER_THAN) {
return (Integer.getInteger(with.constant) > donor.getAmount());
} else if (with.operator == Operator.LESS_THAN) {
return (Integer.getInteger(with.constant) < donor.getAmount());
} else {
return (Integer.getInteger(with.constant) == donor.getAmount());
}
});
default:
throw new UnsupportedOperationException();
}