throw new IllegalArgumentException(
"This method currently only supports logical filters with exactly 2 children.");
}
// we're expecting 2 compare subfilters
PropertyIsGreaterThanOrEqualTo filter1 = (PropertyIsGreaterThanOrEqualTo) children.get(0);
BinaryComparisonOperator filter2 = (BinaryComparisonOperator) children.get(1);
//filter1 should be 1 <= x and filter2 should be x <(=) 5
if (!(filter1.getExpression2().equals(filter2.getExpression1()))) {
throw new IllegalArgumentException(
"Subfilters or subExpressions in incorrect order");
}
if (filter1.getExpression1().toString() != newValue[0]) {
//lower bound value has changed, update
filter1 = ff.greaterOrEqual(filter1.getExpression1(), ff.literal(newValue[0]));
}
if (filter2.getExpression2().toString() != newValue[1]) {
//upper bound value has changed, update
if(filter2 instanceof PropertyIsLessThan) {
filter2 = ff.less(filter1.getExpression1(), ff.literal(newValue[1]));
} else if(filter2 instanceof PropertyIsLessThanOrEqualTo) {
filter2 = ff.lessOrEqual(filter1.getExpression1(), ff.literal(newValue[1]));
} else {
throw new IllegalArgumentException("Filter 2 in the comparison is not less or less or equal??");
}
}