I am trying to use ComparisonChain to implement compareTo () in a class, but the class contains List and compare () does not accept them, because List does not implement Comparable. Any ideas on how to make this work?
A subset of the code looks something like this:
public class User() {
String name;
List<String> emails;
...
public int compareTo(User that) {
return ComparisonChain().start()
.compare(this.name, that.name)
.compare(this.emails, that.emails)
.result();
}
}
source
share