import org.apache.commons.lang3.builder.ToStringBuilder;

public class CSBTS_StringToStringSample {
    static class Person {
        String name;
        int age;

        Person(String name, int age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            // INCORRECT USAGE : The same as invoking Object.toString()
            // return new ToStringBuilder(this).toString();
            // Consider using for non final classes to support a
            // string representation for derived types
            // return ToStringBuilder.reflectionToString(this);
            // Use for final classes most efficient solution
            return new ToStringBuilder(this).append("name", name).append("age", age).toString();
        }
    }

    private enum SEX {
        Male, Female;
    }

    public final static class GenderPerson extends Person {
        private SEX sex;

        GenderPerson(String name, int age, SEX sex) {
            super(name, age);
            this.sex = sex;
        }
    }

    public static void main(String[] args) {
        Person p = new Person("John Doe", 2);
        ToStringBuilder x = new ToStringBuilder(p);
        ToStringBuilder y = new ToStringBuilder(p);
        // INCORRECT USAGE : The same as invoking Object.toString
        System.out.println("P " + new ToStringBuilder(p).toString());
        // Consider using for non final classes to support a string
        // representation for derived types
        System.out.println("P " + ToStringBuilder.reflectionToString(p));
        GenderPerson p2 = new GenderPerson("Jane Doe", 2, SEX.Female);
        System.out.println("GP " + new ToStringBuilder(p2).append("name", p2.name).append("age", p2.age).append("sex", p2.sex).toString());
        // Y now has an append
        y.append("name", p.name);
        System.out.println("P - Once Again " + y.toString());
        System.out.println("P - Again " + x.toString());
    }
}

@@ -1985,20 +1985,507 @@
 oString());%0A
+    %7D%0A    %0A    public class FPNoStore %7B%0A        private String userName;%0A        private String firstName;%0A        private String lastName;%0A        private String email;%0A        %0A        public final String toString() %7B%0A            ToStringBuilder b = new ToStringBuilder(this).%0A            append(%22username%22, userName).%0A            append(%22firstname%22, firstName).%0A            append(%22lastname%22, lastName).%0A            append(%22email%22, email);%0A            return b.toString();%0A        %7D%0A%0A
     %7D%0A%7D%0A

add fp for CSBTS