@Test public void testDataTypes() { assertEquals("Foo =\n" + " Bar\n" + " | Baz", print(new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Foo", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(new Constructor(NO_COMMENTS, "Bar", Util.<Arg> list()), new Constructor(NO_COMMENTS, "Baz", Util.<Arg> list()))))); assertEquals("Foo extends FooA implements FooB, FooC =\n" + " Bar\n" + " | Baz", print(new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Foo", Util.<String>list(), _Some(_ClassType("FooA", NO_TYPE_ARGS)), list(_ClassType("FooB", NO_TYPE_ARGS), _ClassType("FooC", NO_TYPE_ARGS)), list(new Constructor(NO_COMMENTS, "Bar", Util.<Arg> list()), new Constructor(NO_COMMENTS, "Baz", Util.<Arg> list()))))); assertEquals("@foo\n@foo( @bar )\nFoo =\n" + " Bar\n" + " | Baz", print(new DataType(NO_COMMENTS, list(_Annotation("foo", Optional.<AnnotationElement>_None()), _Annotation("foo", _Some(_ElementValue(_AnnotationValueAnnotation(_Annotation("bar", Optional.<AnnotationElement>_None())))))), "Foo", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(new Constructor(NO_COMMENTS, "Bar", Util.<Arg> list()), new Constructor(NO_COMMENTS, "Baz", Util.<Arg> list()))))); }
public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); } }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }  }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }  static String print(Doc doc); static String printComments(String indent, List<JavaComment> comments); static String print(final String indent, JavaComment comment); static String print(DataType dataType); static String print(Constructor constructor); static String print(Arg arg); static String printArgModifiers(List<ArgModifier> modifiers); static String print(Type type); static String print(RefType type); static String print(PrimitiveType type); static String print(ArgModifier modifier); static String print(final Literal literal); static String print(Expression expression); static String print(Annotation annotation); static String print(AnnotationElement value); static String print(AnnotationValue value); static String print(BinaryOperator op); }
ASTPrinter { public static String print(Doc doc) { final StringBuilder builder = new StringBuilder(doc.pkg.name.isEmpty() ? "" : ("package " + doc.pkg.name + "\n\n")); if (!doc.imports.isEmpty()) { for (Imprt imp : doc.imports) { builder.append("import " + imp.name + "\n"); } builder.append("\n"); } for (DataType dataType : doc.dataTypes) { builder.append(print(dataType)); builder.append("\n"); } return builder.toString(); }  static String print(Doc doc); static String printComments(String indent, List<JavaComment> comments); static String print(final String indent, JavaComment comment); static String print(DataType dataType); static String print(Constructor constructor); static String print(Arg arg); static String printArgModifiers(List<ArgModifier> modifiers); static String print(Type type); static String print(RefType type); static String print(PrimitiveType type); static String print(ArgModifier modifier); static String print(final Literal literal); static String print(Expression expression); static String print(Annotation annotation); static String print(AnnotationElement value); static String print(AnnotationValue value); static String print(BinaryOperator op);  }