@Test public void testCompareTo() throws Exception { List<LookupUsage> usages = Lists.newArrayList(); usages.add(new LookupUsage(443, "Abies", "Mill.", "1978", Rank.GENUS, ACCEPTED, PLANTAE, false)); usages.add(new LookupUsage(13, "Abies milba", "Mill.", "1978", Rank.SPECIES, ACCEPTED, PLANTAE, false)); usages.add(new LookupUsage(3, "Abies alba", "Mill.", "1978", Rank.SPECIES, ACCEPTED, PLANTAE, false)); usages.add(new LookupUsage(5323, "Papaia", "L.", "1978", Rank.GENUS, ACCEPTED, ANIMALIA, false)); usages.add(new LookupUsage(23, "Abia giganta", "Mill.", "1978", Rank.SPECIES, ACCEPTED, ANIMALIA, false)); usages.add(new LookupUsage(113, "Keine AHnung", null, null, Rank.UNRANKED, ACCEPTED, INCERTAE_SEDIS, true)); usages.add(new LookupUsage(88, "Keiner", null, null, Rank.SUPERFAMILY, ACCEPTED, INCERTAE_SEDIS, true)); Collections.sort(usages); assertEquals(88, usages.get(0).getKey()); assertEquals(5323, usages.get(1).getKey()); assertEquals(443, usages.get(2).getKey()); assertEquals(23, usages.get(3).getKey()); assertEquals(3, usages.get(4).getKey()); assertEquals(13, usages.get(5).getKey()); assertEquals(113, usages.get(6).getKey()); }
@Override public int compareTo(LookupUsage that) { return ComparisonChain.start() .compare(this.rank, that.rank, Ordering.natural().nullsLast()) .compare(this.kingdom, that.kingdom, Ordering.natural().nullsLast()) .compare(this.canonical, that.canonical, Ordering.natural().nullsLast()) .compare(this.status, that.status, Ordering.natural().nullsLast()) .result(); }
LookupUsage implements Comparable<LookupUsage> { @Override public int compareTo(LookupUsage that) { return ComparisonChain.start() .compare(this.rank, that.rank, Ordering.natural().nullsLast()) .compare(this.kingdom, that.kingdom, Ordering.natural().nullsLast()) .compare(this.canonical, that.canonical, Ordering.natural().nullsLast()) .compare(this.status, that.status, Ordering.natural().nullsLast()) .result(); } }
LookupUsage implements Comparable<LookupUsage> { @Override public int compareTo(LookupUsage that) { return ComparisonChain.start() .compare(this.rank, that.rank, Ordering.natural().nullsLast()) .compare(this.kingdom, that.kingdom, Ordering.natural().nullsLast()) .compare(this.canonical, that.canonical, Ordering.natural().nullsLast()) .compare(this.status, that.status, Ordering.natural().nullsLast()) .result(); } LookupUsage();  LookupUsage(int key, String canonical, String authorship, String year, Rank rank, TaxonomicStatus status, Kingdom kingdom, boolean deleted);  LookupUsage(int key, Int2IntMap proParteKeys, String canonical, String authorship, String year, Rank rank, TaxonomicStatus status, Kingdom kingdom, boolean deleted); }
LookupUsage implements Comparable<LookupUsage> { @Override public int compareTo(LookupUsage that) { return ComparisonChain.start() .compare(this.rank, that.rank, Ordering.natural().nullsLast()) .compare(this.kingdom, that.kingdom, Ordering.natural().nullsLast()) .compare(this.canonical, that.canonical, Ordering.natural().nullsLast()) .compare(this.status, that.status, Ordering.natural().nullsLast()) .result(); } LookupUsage();  LookupUsage(int key, String canonical, String authorship, String year, Rank rank, TaxonomicStatus status, Kingdom kingdom, boolean deleted);  LookupUsage(int key, Int2IntMap proParteKeys, String canonical, String authorship, String year, Rank rank, TaxonomicStatus status, Kingdom kingdom, boolean deleted); String getAuthorship(); void setAuthorship(String authorship); String getYear(); void setYear(String year); String getCanonical(); void setCanonical(String canonical); int getKey(); void setKey(int key); Int2IntMap getProParteKeys(); TaxonomicStatus getStatus(); void setStatus(TaxonomicStatus status); Kingdom getKingdom(); void setKingdom(Kingdom kingdom); Rank getRank(); void setRank(Rank rank); boolean isDeleted(); void setDeleted(boolean deleted); int getMaxKey(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(LookupUsage that); }
LookupUsage implements Comparable<LookupUsage> { @Override public int compareTo(LookupUsage that) { return ComparisonChain.start() .compare(this.rank, that.rank, Ordering.natural().nullsLast()) .compare(this.kingdom, that.kingdom, Ordering.natural().nullsLast()) .compare(this.canonical, that.canonical, Ordering.natural().nullsLast()) .compare(this.status, that.status, Ordering.natural().nullsLast()) .result(); } LookupUsage();  LookupUsage(int key, String canonical, String authorship, String year, Rank rank, TaxonomicStatus status, Kingdom kingdom, boolean deleted);  LookupUsage(int key, Int2IntMap proParteKeys, String canonical, String authorship, String year, Rank rank, TaxonomicStatus status, Kingdom kingdom, boolean deleted); String getAuthorship(); void setAuthorship(String authorship); String getYear(); void setYear(String year); String getCanonical(); void setCanonical(String canonical); int getKey(); void setKey(int key); Int2IntMap getProParteKeys(); TaxonomicStatus getStatus(); void setStatus(TaxonomicStatus status); Kingdom getKingdom(); void setKingdom(Kingdom kingdom); Rank getRank(); void setRank(Rank rank); boolean isDeleted(); void setDeleted(boolean deleted); int getMaxKey(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(LookupUsage that);  }