GClass { public String toString() { return this.getFullName(); } GClass(String fullClassName);  GClass(GDirectory directory, String fullClassName); GDirectory getDirectory(); GClass setEnum(); GClass setInterface(); GClass addEnumValue(String value, Object... args); GClass addGetterSetter(String type, String name); boolean isSameClass(String fullNameWithOrWithoutGenerics); GClass getInnerClass(String name, Object... args); GClass notStatic(); GMethod getConstructor(String... typeAndNames); GMethod getConstructor(Argument arg0, Argument... _args); GMethod getConstructor(List<Argument> _args); boolean hasMethod(String name); GMethod getMethod(String name, Object... args); GMethod getMethod(String name, Argument arg0, Argument... _args); GMethod getMethod(String name, List<Argument> _args); GField getField(String name, Object... args); String toCode(); GClass setAbstract(); GClass setPackagePrivate(); GClass setPrivate(); GClass setAccess(Access access); GClass setAnonymous(); GClass addImports(Class<?>... types); GClass addImports(String... importClassNames); String getBaseClassName(); String getBaseQualifiedClassName(); GClass baseClass(Class<?> type); GClass baseClassName(String baseClassName, Object... args); String stripAndImportPackageIfPossible(String fullClassName); List<GMethod> getConstructors(); String toString(); String getPackageName(); String getSimpleName(); String getFullName(); String getFileName(); GClass implementsInterface(Class<?> interfaceClass); GClass implementsInterface(String interfaceFullName, Object... args); GClass addAnnotation(String annotation, Object... args); GClass addEquals(); GClass addEquals(String... fieldNames); GClass addEquals(Collection<String> fieldNames); GClass addHashCode(); GClass addHashCode(String... fieldNames); GClass addHashCode(Collection<String> fieldNames); GClass addToString(); GClass addToString(String... fieldNames); GClass addToString(Collection<String> fieldNames); final StringBuilderr staticInitializer; }
@Test public void testToString() { GClass gc = new GClass("Foo"); gc.getField("foo").type("String"); gc.getField("bar").type("boolean"); gc.getField("zaz").type("String[]"); gc.addToString(); Assert.assertEquals(Join.lines( "public class Foo {", "", " private String foo;", " private boolean bar;", " private String[] zaz;", "", " @Override", " public String toString() {", " return \"Foo[\"", " + foo", " + \", \"", " + bar", " + \", \"", " + java.util.Arrays.toString(zaz)", " + \"]\";", " }", "", "}", ""), gc.toCode()); }