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());
}
Aggregations