@Test public void testCompareTo() throws Exception { IntentEntry one = new IntentEntry(member1,LockMode.UNLOCKED,100L,500L); IntentEntry two = new IntentEntry(member2,LockMode.UNLOCKED,200L,400L); IntentEntry three = new IntentEntry(member3,LockMode.UNLOCKED,300L,300L); IntentEntry four = new IntentEntry(member3,LockMode.UNLOCKED,400L,200L); IntentEntry five = new IntentEntry(member3,LockMode.UNLOCKED,500L,100L); List<IntentEntry> sortedByUpdateOrAcquire = Arrays.asList(three,two,four,five,one); Collections.sort(sortedByUpdateOrAcquire); assertEquals(Arrays.asList(five,four,three,two,one),sortedByUpdateOrAcquire); }
public int compareTo(IntentEntry other){ int compET = Long.compare(this.lastUnlockedOrAcquired,other.lastUnlockedOrAcquired); if (compET != 0) return compET; return tiebreaker(this.member, other.member); }
IntentEntry implements Comparable<IntentEntry> { public int compareTo(IntentEntry other){ int compET = Long.compare(this.lastUnlockedOrAcquired,other.lastUnlockedOrAcquired); if (compET != 0) return compET; return tiebreaker(this.member, other.member); } }
IntentEntry implements Comparable<IntentEntry> { public int compareTo(IntentEntry other){ int compET = Long.compare(this.lastUnlockedOrAcquired,other.lastUnlockedOrAcquired); if (compET != 0) return compET; return tiebreaker(this.member, other.member); } IntentEntry(InetSocketAddress member,LockMode state,long published);  IntentEntry(InetSocketAddress member,LockMode state,long published, long lastUnlockedOrAcquired); }
IntentEntry implements Comparable<IntentEntry> { public int compareTo(IntentEntry other){ int compET = Long.compare(this.lastUnlockedOrAcquired,other.lastUnlockedOrAcquired); if (compET != 0) return compET; return tiebreaker(this.member, other.member); } IntentEntry(InetSocketAddress member,LockMode state,long published);  IntentEntry(InetSocketAddress member,LockMode state,long published, long lastUnlockedOrAcquired); boolean isFor(InetSocketAddress myID); boolean isPublishedBefore(IntentEntry someEntry); boolean isPublishedAfter(IntentEntry someEntry); boolean isEnteredBefore(IntentEntry other); boolean isAckedBy(IntentEntry entry); boolean isAnAcquire(); static int tiebreaker(InetSocketAddress addr1, InetSocketAddress addr2); int compareTo(IntentEntry other); String toString(); }
IntentEntry implements Comparable<IntentEntry> { public int compareTo(IntentEntry other){ int compET = Long.compare(this.lastUnlockedOrAcquired,other.lastUnlockedOrAcquired); if (compET != 0) return compET; return tiebreaker(this.member, other.member); } IntentEntry(InetSocketAddress member,LockMode state,long published);  IntentEntry(InetSocketAddress member,LockMode state,long published, long lastUnlockedOrAcquired); boolean isFor(InetSocketAddress myID); boolean isPublishedBefore(IntentEntry someEntry); boolean isPublishedAfter(IntentEntry someEntry); boolean isEnteredBefore(IntentEntry other); boolean isAckedBy(IntentEntry entry); boolean isAnAcquire(); static int tiebreaker(InetSocketAddress addr1, InetSocketAddress addr2); int compareTo(IntentEntry other); String toString(); public InetSocketAddress member; public long published; public long lastUnlockedOrAcquired; public LockMode state; }