ExpressionVisitorImpl implements ExpressionVisitor<Object> { @Override public Object visitLiteralExpression(LiteralExpression literalExpression) { if (Objects.equals( LiteralExpression.Type.DATE, literalExpression.getType()) || Objects.equals( LiteralExpression.Type.DATE_TIME, literalExpression.getType())) { return _normalizeDateLiteral(literalExpression.getText()); } else if (Objects.equals( LiteralExpression.Type.STRING, literalExpression.getType())) { return _normalizeStringLiteral(literalExpression.getText()); } return literalExpression.getText(); } 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 testVisitDateISO8601LiteralExpression() { LiteralExpression literalExpression = new LiteralExpressionImpl( "2012-05-29T09:13:28Z", LiteralExpression.Type.DATE_TIME); Assert.assertEquals( "20120529091328", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }
@Test public void testVisitDateISOLiteralExpression() { LiteralExpression literalExpression = new LiteralExpressionImpl( "2012-05-29T11:58:16+00:00", LiteralExpression.Type.DATE_TIME); Assert.assertEquals( "20120529115816", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }
@Test public void testVisitDateUTCLiteralExpression() { LiteralExpression literalExpression = new LiteralExpressionImpl( "2012-05-29", LiteralExpression.Type.DATE); Assert.assertEquals( "20120529000000", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }
@Test public void testVisitStringLiteralExpressionWithDoubleSingleQuotes() { LiteralExpression literalExpression = new LiteralExpressionImpl( "'L''Oreal'", LiteralExpression.Type.STRING); Assert.assertEquals( "l'oreal", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }
@Test public void testVisitStringLiteralExpressionWithMultipleDoubleSingleQuotes() { LiteralExpression literalExpression = new LiteralExpressionImpl( "'L''Oreal and L''Oreal'", LiteralExpression.Type.STRING); Assert.assertEquals( "l'oreal and l'oreal", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }
@Test public void testVisitStringLiteralExpressionWithOneSingleQuote() { LiteralExpression literalExpression = new LiteralExpressionImpl( "'L'Oreal'", LiteralExpression.Type.STRING); Assert.assertEquals( "l'oreal", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }
@Test public void testVisitStringLiteralExpressionWithSurroundingSingleQuotes() { LiteralExpression literalExpression = new LiteralExpressionImpl( "'LOreal'", LiteralExpression.Type.STRING); Assert.assertEquals( "loreal", _expressionVisitorImpl.visitLiteralExpression(literalExpression)); }