@Test public void testQueryBuilderLike() throws Exception { try (Session session = getSession()) { QueryBuilder queryBuilder = new QueryBuilder().predicate(Predicates.like("firstName", "foobar")) .and(Predicates.like("firstName", "foo%bar")) .and(Predicates.like("firstName", "foo_bar")) .and(Predicates.like("firstName", "foo\\%bar")) .and(Predicates.like("firstName", "foo\\_bar")) .and(Predicates.like("firstName", "foo\\\\bar")); LDAPFilterBuilder builder = new LDAPFilterBuilder(getDirectory()); builder.walk(queryBuilder.predicate()); assertEquals("(&" + "(givenName={0})" + "(givenName={1}*{2})" + "(givenName={3})" + "(givenName={4})" + "(givenName={5})" + "(givenName={6})" + ")", builder.filter.toString()); assertEqualsNormalized(Arrays.asList( "foobar", "foo", "bar", "foo_bar", "foo%bar", "foo_bar", "foo\\bar" ), builder.params.stream().collect(toList())); } }
public void walk(Expression expression) { if (expression instanceof MultiExpression && ((MultiExpression) expression).predicates.isEmpty()) { return; } else { walkExpression(expression); } }
LDAPFilterBuilder { public void walk(Expression expression) { if (expression instanceof MultiExpression && ((MultiExpression) expression).predicates.isEmpty()) { return; } else { walkExpression(expression); } } }
LDAPFilterBuilder { public void walk(Expression expression) { if (expression instanceof MultiExpression && ((MultiExpression) expression).predicates.isEmpty()) { return; } else { walkExpression(expression); } } LDAPFilterBuilder(LDAPDirectory directory); }
LDAPFilterBuilder { public void walk(Expression expression) { if (expression instanceof MultiExpression && ((MultiExpression) expression).predicates.isEmpty()) { return; } else { walkExpression(expression); } } LDAPFilterBuilder(LDAPDirectory directory); void walk(Expression expression); void walkExpression(Expression expr); void walkNot(Operand value); void walkIsNull(Operand value); void walkIsNotNull(Operand value); void walkAndMultiExpression(MultiExpression expr); void walkAnd(Expression expr); void walkOrMultiExpression(MultiExpression expr); void walkOr(Expression expr); void walkEq(Operand lvalue, Operand rvalue); void walkNotEq(Operand lvalue, Operand rvalue); void walkLt(Operand lvalue, Operand rvalue); void walkGt(Operand lvalue, Operand rvalue); void walkLtEq(Operand lvalue, Operand rvalue); void walkGtEq(Operand lvalue, Operand rvalue); void walkBetween(Operand lvalue, Operand rvalue, boolean positive); void walkIn(Operand lvalue, Operand rvalue, boolean positive); void walkLike(Operand lvalue, Operand rvalue, boolean positive, boolean caseInsensitive); void walkLikeWildcard(String like); void walkOperand(Operand operand); void walkLiteral(Operand operand); void walkBooleanLiteral(BooleanLiteral lit); void walkDateLiteral(DateLiteral lit); void walkDoubleLiteral(DoubleLiteral lit); void walkIntegerLiteral(IntegerLiteral lit); void walkStringLiteral(StringLiteral lit); Object walkFunction(Function func); Field walkReference(Operand value); }
LDAPFilterBuilder { public void walk(Expression expression) { if (expression instanceof MultiExpression && ((MultiExpression) expression).predicates.isEmpty()) { return; } else { walkExpression(expression); } } LDAPFilterBuilder(LDAPDirectory directory); void walk(Expression expression); void walkExpression(Expression expr); void walkNot(Operand value); void walkIsNull(Operand value); void walkIsNotNull(Operand value); void walkAndMultiExpression(MultiExpression expr); void walkAnd(Expression expr); void walkOrMultiExpression(MultiExpression expr); void walkOr(Expression expr); void walkEq(Operand lvalue, Operand rvalue); void walkNotEq(Operand lvalue, Operand rvalue); void walkLt(Operand lvalue, Operand rvalue); void walkGt(Operand lvalue, Operand rvalue); void walkLtEq(Operand lvalue, Operand rvalue); void walkGtEq(Operand lvalue, Operand rvalue); void walkBetween(Operand lvalue, Operand rvalue, boolean positive); void walkIn(Operand lvalue, Operand rvalue, boolean positive); void walkLike(Operand lvalue, Operand rvalue, boolean positive, boolean caseInsensitive); void walkLikeWildcard(String like); void walkOperand(Operand operand); void walkLiteral(Operand operand); void walkBooleanLiteral(BooleanLiteral lit); void walkDateLiteral(DateLiteral lit); void walkDoubleLiteral(DoubleLiteral lit); void walkIntegerLiteral(IntegerLiteral lit); void walkStringLiteral(StringLiteral lit); Object walkFunction(Function func); Field walkReference(Operand value); public StringBuilder filter; public int paramIndex; final List<Serializable> params; }