Guava ComparisonChain Wtih List?

Viewed 2603

I'm attempting to use ComparisonChain to implement compareTo() in a class however the class contains a List and compare() doesn't accept them because List doesn't implement Comparable. Any ideas on how to make this work?

Subset of 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)  // Fails on this line
                            .result();
  }
}
1 Answers
Related