Search in sources :

Example 1 with FieldDeclaration

use of org.apache.calcite.linq4j.tree.FieldDeclaration in project calcite by apache.

the class ExpressionTest method testClassDecl.

@Test
public void testClassDecl() {
    final NewExpression newExpression = Expressions.new_(Object.class, Collections.<Expression>emptyList(), Arrays.<MemberDeclaration>asList(Expressions.fieldDecl(Modifier.PUBLIC | Modifier.FINAL, Expressions.parameter(String.class, "foo"), Expressions.constant("bar")), new ClassDeclaration(Modifier.PUBLIC | Modifier.STATIC, "MyClass", null, Collections.<Type>emptyList(), Arrays.<MemberDeclaration>asList(new FieldDeclaration(0, Expressions.parameter(int.class, "x"), Expressions.constant(0)))), Expressions.fieldDecl(0, Expressions.parameter(int.class, "i"))));
    assertEquals("new Object(){\n" + "  public final String foo = \"bar\";\n" + "  public static class MyClass {\n" + "    int x = 0;\n" + "  }\n" + "  int i;\n" + "}", Expressions.toString(newExpression));
    newExpression.accept(new Shuttle());
}
Also used : ClassDeclaration(org.apache.calcite.linq4j.tree.ClassDeclaration) NewExpression(org.apache.calcite.linq4j.tree.NewExpression) Shuttle(org.apache.calcite.linq4j.tree.Shuttle) FieldDeclaration(org.apache.calcite.linq4j.tree.FieldDeclaration) Test(org.junit.Test)

Aggregations

ClassDeclaration (org.apache.calcite.linq4j.tree.ClassDeclaration)1 FieldDeclaration (org.apache.calcite.linq4j.tree.FieldDeclaration)1 NewExpression (org.apache.calcite.linq4j.tree.NewExpression)1 Shuttle (org.apache.calcite.linq4j.tree.Shuttle)1 Test (org.junit.Test)1