Java 类com.facebook.presto.sql.tree.LambdaExpression 实例源码

项目:presto-query-formatter    文件:ExpressionFormatter.java   
@Override
protected String visitLambdaExpression(LambdaExpression node, StackableAstVisitorContext<Integer> indent)
{
    StringBuilder builder = new StringBuilder();

    builder.append('(');
    Joiner.on(", ").appendTo(builder, node.getArguments());
    builder.append(") -> ");
    builder.append(process(node.getBody(), indent));
    return builder.toString();
}
项目:presto    文件:AstBuilder.java   
@Override
public Node visitLambda(SqlBaseParser.LambdaContext context)
{
    List<String> arguments = context.identifier().stream()
            .map(SqlBaseParser.IdentifierContext::getText)
            .collect(toList());

    Expression body = (Expression) visit(context.expression());

    return new LambdaExpression(arguments, body);
}
项目:presto    文件:ExpressionFormatter.java   
@Override
protected String visitLambdaExpression(LambdaExpression node, Boolean unmangleNames)
{
    StringBuilder builder = new StringBuilder();

    builder.append('(');
    Joiner.on(", ").appendTo(builder, node.getArguments());
    builder.append(") -> ");
    builder.append(process(node.getBody(), unmangleNames));
    return builder.toString();
}
项目:presto    文件:TestSqlParser.java   
@Test
public void testLambda()
        throws Exception
{
    assertExpression("x -> sin(x)",
            new LambdaExpression(
                    ImmutableList.of("x"),
                    new FunctionCall(QualifiedName.of("sin"), ImmutableList.of(new QualifiedNameReference(QualifiedName.of("x"))))));
    assertExpression("(x, y) -> mod(x, y)",
            new LambdaExpression(
                    ImmutableList.of("x", "y"),
                    new FunctionCall(
                            QualifiedName.of("mod"),
                            ImmutableList.of(new QualifiedNameReference(QualifiedName.of("x")), new QualifiedNameReference(QualifiedName.of("y"))))));
}
项目:EchoQuery    文件:ExpressionFormatter.java   
@Override
protected String visitLambdaExpression(LambdaExpression node, Boolean unmangleNames)
{
    StringBuilder builder = new StringBuilder();

    builder.append('(');
    Joiner.on(", ").appendTo(builder, node.getArguments());
    builder.append(") -> ");
    builder.append(process(node.getBody(), unmangleNames));
    return builder.toString();
}