use of org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString in project fb-contrib by mebigfatguy.
the class CSBTS_StringToStringSample method main.
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());
}
Aggregations