@Test public void testProcessToString() { MethodSpec.Builder toStringBuilder = MethodSpec.methodBuilder("toString") .addModifiers(Modifier.PUBLIC) .returns(String.class); List<String> fields = Arrays.asList("one", "two"); MetaInfo metaInfo = new MetaInfo("Test", "com.flipkart.lyrics"); CommonsLang3Style style = new CommonsLang3Style(); style.processToString(toStringBuilder, fields, metaInfo); MethodSpec toString = toStringBuilder.build(); assertEquals("toString", toString.name); assertEquals(0, toString.parameters.size()); }
@Override public void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo) { ClassName toStringBuilderClass = ClassName.get(ToStringBuilder.class); toStringBuilder.addCode("return new $T(this)\n", toStringBuilderClass); for (String field : nonStaticFields) { toStringBuilder.addCode("\t\t.append($S, $L)\n", field, field); } toStringBuilder.addCode("\t\t.toString();\n"); }
CommonsLang3Style extends ObjectMethodsStyle { @Override public void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo) { ClassName toStringBuilderClass = ClassName.get(ToStringBuilder.class); toStringBuilder.addCode("return new $T(this)\n", toStringBuilderClass); for (String field : nonStaticFields) { toStringBuilder.addCode("\t\t.append($S, $L)\n", field, field); } toStringBuilder.addCode("\t\t.toString();\n"); } }
CommonsLang3Style extends ObjectMethodsStyle { @Override public void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo) { ClassName toStringBuilderClass = ClassName.get(ToStringBuilder.class); toStringBuilder.addCode("return new $T(this)\n", toStringBuilderClass); for (String field : nonStaticFields) { toStringBuilder.addCode("\t\t.append($S, $L)\n", field, field); } toStringBuilder.addCode("\t\t.toString();\n"); }  }
CommonsLang3Style extends ObjectMethodsStyle { @Override public void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo) { ClassName toStringBuilderClass = ClassName.get(ToStringBuilder.class); toStringBuilder.addCode("return new $T(this)\n", toStringBuilderClass); for (String field : nonStaticFields) { toStringBuilder.addCode("\t\t.append($S, $L)\n", field, field); } toStringBuilder.addCode("\t\t.toString();\n"); }  @Override void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo); @Override void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality); }
CommonsLang3Style extends ObjectMethodsStyle { @Override public void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo) { ClassName toStringBuilderClass = ClassName.get(ToStringBuilder.class); toStringBuilder.addCode("return new $T(this)\n", toStringBuilderClass); for (String field : nonStaticFields) { toStringBuilder.addCode("\t\t.append($S, $L)\n", field, field); } toStringBuilder.addCode("\t\t.toString();\n"); }  @Override void processToString(MethodSpec.Builder toStringBuilder, List<String> nonStaticFields, MetaInfo metaInfo); @Override void processEqualsAndHashCode(MethodSpec.Builder equalsBuilder, MethodSpec.Builder hashCodeBuilder, List<String> nonStaticFields, MetaInfo metaInfo, boolean testSuperEquality);  }