@Test public void compareToWithCoincidentItems() { FakeItem first = new FakeItem( "1", 10L ); FakeItem second = new FakeItem( "1", 10L ); FakeItem subSequent = new FakeItem( "1", 20L ); assertThat( first ).isCoincidentTo( second ); assertThat( second ).isCoincidentTo( first ); assertThat( signum( first.compareTo( second ) ) == -signum( second.compareTo( first ) ) ); assertThat( signum( first.compareTo( subSequent ) ) == signum( second.compareTo( subSequent ) ) ); }
@Override public int compareTo( Item item ) { int result = Long.compare( getTimeStamp(), item.getTimeStamp() ); if( result == 0 ) { result = getId().compareTo( item.getId() ); } return result; }
Item implements Comparable<Item> { @Override public int compareTo( Item item ) { int result = Long.compare( getTimeStamp(), item.getTimeStamp() ); if( result == 0 ) { result = getId().compareTo( item.getId() ); } return result; } }
Item implements Comparable<Item> { @Override public int compareTo( Item item ) { int result = Long.compare( getTimeStamp(), item.getTimeStamp() ); if( result == 0 ) { result = getId().compareTo( item.getId() ); } return result; } Item( String id , long timeStamp   ); }
Item implements Comparable<Item> { @Override public int compareTo( Item item ) { int result = Long.compare( getTimeStamp(), item.getTimeStamp() ); if( result == 0 ) { result = getId().compareTo( item.getId() ); } return result; } Item( String id , long timeStamp   ); long getTimeStamp(); String getId(); @Override int compareTo( Item item ); @Override int hashCode(); @Override boolean equals( Object obj ); }
Item implements Comparable<Item> { @Override public int compareTo( Item item ) { int result = Long.compare( getTimeStamp(), item.getTimeStamp() ); if( result == 0 ) { result = getId().compareTo( item.getId() ); } return result; } Item( String id , long timeStamp   ); long getTimeStamp(); String getId(); @Override int compareTo( Item item ); @Override int hashCode(); @Override boolean equals( Object obj );  }