ExpressionVisitorImpl implements ExpressionVisitor<Object> { @Override public Object visitMemberExpression(MemberExpression memberExpression) throws ExpressionVisitException { Expression expression = memberExpression.getExpression(); return expression.accept(this); } ExpressionVisitorImpl(
		Format format, Locale locale, EntityModel entityModel); @Override Filter visitBinaryExpressionOperation(
		BinaryExpression.Operation operation, Object left, Object right); @Override Object visitCollectionPropertyExpression(
			CollectionPropertyExpression collectionPropertyExpression); @Override Object visitComplexPropertyExpression(
		ComplexPropertyExpression complexPropertyExpression); @Override Object visitLambdaFunctionExpression(
			LambdaFunctionExpression.Type type, String variable,
			Expression expression); @Override EntityField visitLambdaVariableExpression(
			LambdaVariableExpression lambdaVariableExpression); @Override Object visitListExpressionOperation(
			ListExpression.Operation operation, Object left, List<Object> right); @Override Object visitLiteralExpression(LiteralExpression literalExpression); @Override Object visitMemberExpression(MemberExpression memberExpression); @Override Object visitMethodExpression(
		List<Object> expressions, MethodExpression.Type type); @Override Object visitPrimitivePropertyExpression(
		PrimitivePropertyExpression primitivePropertyExpression); @Override Filter visitUnaryExpressionOperation(
		UnaryExpression.Operation operation, Object operand);  }
@Test public void testVisitMemberExpressionComplexField() throws ExpressionVisitException { MemberExpression memberExpression = new MemberExpressionImpl( new ComplexPropertyExpressionImpl( "values", new PrimitivePropertyExpressionImpl("value1"))); EntityField entityField = (EntityField)_expressionVisitorImpl.visitMemberExpression( memberExpression); Assert.assertNotNull(entityField); Assert.assertEquals("value1", entityField.getName()); Assert.assertEquals(EntityField.Type.STRING, entityField.getType()); }
@Test public void testVisitMemberExpressionLambdaAnyOnCollectionField() throws ExpressionVisitException { MemberExpression memberExpression = new MemberExpressionImpl( new CollectionPropertyExpressionImpl( new PrimitivePropertyExpressionImpl("keywords"), new LambdaFunctionExpressionImpl( LambdaFunctionExpression.Type.ANY, "k", new BinaryExpressionImpl( new MemberExpressionImpl( new LambdaVariableExpressionImpl("k")), BinaryExpression.Operation.EQ, new LiteralExpressionImpl( "'keyword1'", LiteralExpression.Type.STRING))))); TermFilter termFilter = (TermFilter)_expressionVisitorImpl.visitMemberExpression( memberExpression); Assert.assertNotNull(termFilter); Assert.assertEquals("keywords.raw", termFilter.getField()); Assert.assertEquals("keyword1", termFilter.getValue()); }
@Test public void testVisitMemberExpressionStringEntityField() throws ExpressionVisitException { MemberExpression memberExpression = new MemberExpressionImpl( new PrimitivePropertyExpressionImpl("title")); EntityField entityField = (EntityField)_expressionVisitorImpl.visitMemberExpression( memberExpression); Assert.assertNotNull(entityField); Assert.assertEquals("title", entityField.getName()); Assert.assertEquals(EntityField.Type.STRING, entityField.getType()); }
@Test public void testVisitMemberExpressionStringEntityFieldInLambda() throws ExpressionVisitException { Map<String, EntityField> entityFieldsMap = _entityModel.getEntityFieldsMap(); EntityField entityField1 = entityFieldsMap.get("keywords"); ExpressionVisitorImpl expressionVisitorImpl = new ExpressionVisitorImpl( new SimpleDateFormat("yyyyMMddHHmmss"), LocaleUtil.getDefault(), new EntityModel() { @Override public Map<String, EntityField> getEntityFieldsMap() { return Collections.singletonMap("k", entityField1); } @Override public String getName() { return entityField1.getName(); } }); MemberExpression memberExpression = new MemberExpressionImpl( new LambdaVariableExpressionImpl("k")); EntityField entityField2 = (EntityField)expressionVisitorImpl.visitMemberExpression( memberExpression); Assert.assertNotNull(entityField2); Assert.assertEquals("keywords", entityField2.getName()); Assert.assertEquals( EntityField.Type.COLLECTION, entityField2.getType()); }