Here CompareToBuilder is used to implement compareTo();
public int compareTo(Person person) {
return new CompareToBuilder()
append(this.firstName, person.firstName)
append(this.lastName, person.firstName)
toComparison();
}
Also, there is yet another reflection option:
public int compareTo(Object o) {
return CompareToBuilder.reflectionCompare(this, o);
}