/** * Sets this filter to ignore the case in a property comparison when using the EQUALS operator. * * @return the same filter instance * @throws IllegalStateException if the filters function is null, not a property comparison or the operator of the * is not an EQUALS-operator. * @since 3.1.1 */ public Filter ignoreCase() { if (!(this.function instanceof PropertyComparison)) { throw new IllegalStateException("ignoreCase is only supported for a filter based on property comparison"); } else if (this.getComparisonOperator() != EQUALS) { throw new IllegalStateException( String.format("ignoreCase is only supported for %s comparison", ComparisonOperator.EQUALS.name())); } this.function = new CaseInsensitiveEqualsComparison((PropertyComparison) this.function); return this; }
@Override public String expression(final String nodeIdentifier) { final Filter filter = this.getFilter(); return String.format("toLower(%s.`%s`) %s toLower({ `%s` }) ", nodeIdentifier, filter.getPropertyName(), ComparisonOperator.EQUALS.getValue(), filter.uniqueParameterName()); } }