private void validateSubExpressionAgainstPreviouslySeen(String normalizedSubExpression, boolean grouped,
boolean membership) throws InvalidExpressionException {
normalizedSubExpression = stripFunctionSuffix(normalizedSubExpression);
if (grouped) {
if (groupedSubExpressions.contains(normalizedSubExpression)) {
throw new InvalidExpressionException("Redundant 'groupby' expression[" + normalizedSubExpression
+ "] - these expressions must be unique");
}
if (simpleSubExpressions.contains(normalizedSubExpression)) {
throw new InvalidExpressionException(
"Can not group by the same condition you are filtering on, expression[" + normalizedSubExpression
+ "]");
}
groupedSubExpressions.add(normalizedSubExpression);
} else if (membership) {
if (memberSubExpressions.contains(normalizedSubExpression)) {
throw new InvalidExpressionException("Redundant 'memberof' expression[" + normalizedSubExpression
+ "] - these expressions must be unique");
}
memberSubExpressions.add(normalizedSubExpression);
} else {
if (groupedSubExpressions.contains(normalizedSubExpression)) {
throw new InvalidExpressionException(
"Can not group by the same condition you are filtering on, expression[" + normalizedSubExpression
+ "]");
}
simpleSubExpressions.add(normalizedSubExpression);
}