@Test public void testShardIndexOrder() { final Shard first = new Shard( 1, 1, false ); final Shard second = new Shard( 2, 1, false ); assertTrue( first.compareTo( second ) < 0 ); assertTrue( second.compareTo( first ) > 0 ); }
@Override public int compareTo( final Shard o ) { if ( o == null ) { return 1; } if ( shardIndex > o.shardIndex ) { return 1; } else if ( shardIndex == o.shardIndex ) { if ( createdTime > o.createdTime ) { return 1; } else if ( createdTime < o.createdTime ) { return -1; } else { if ( compacted && !o.compacted ) { return 1; } else if ( !compacted && o.compacted ){ return -1; } } return 0; } return -1; }
Shard implements Comparable<Shard> { @Override public int compareTo( final Shard o ) { if ( o == null ) { return 1; } if ( shardIndex > o.shardIndex ) { return 1; } else if ( shardIndex == o.shardIndex ) { if ( createdTime > o.createdTime ) { return 1; } else if ( createdTime < o.createdTime ) { return -1; } else { if ( compacted && !o.compacted ) { return 1; } else if ( !compacted && o.compacted ){ return -1; } } return 0; } return -1; } }
Shard implements Comparable<Shard> { @Override public int compareTo( final Shard o ) { if ( o == null ) { return 1; } if ( shardIndex > o.shardIndex ) { return 1; } else if ( shardIndex == o.shardIndex ) { if ( createdTime > o.createdTime ) { return 1; } else if ( createdTime < o.createdTime ) { return -1; } else { if ( compacted && !o.compacted ) { return 1; } else if ( !compacted && o.compacted ){ return -1; } } return 0; } return -1; } Shard( final long shardIndex, final long createdTime, final boolean compacted ); }
Shard implements Comparable<Shard> { @Override public int compareTo( final Shard o ) { if ( o == null ) { return 1; } if ( shardIndex > o.shardIndex ) { return 1; } else if ( shardIndex == o.shardIndex ) { if ( createdTime > o.createdTime ) { return 1; } else if ( createdTime < o.createdTime ) { return -1; } else { if ( compacted && !o.compacted ) { return 1; } else if ( !compacted && o.compacted ){ return -1; } } return 0; } return -1; } Shard( final long shardIndex, final long createdTime, final boolean compacted ); long getShardIndex(); long getCreatedTime(); boolean isCompacted(); void setCompacted(final boolean compacted); boolean isMinShard(); void setShardEnd(final Optional<DirectedEdge> shardEnd); Optional<DirectedEdge> getShardEnd(); boolean isDeleted(); void setDeleted( final boolean deleted); @Override int compareTo( final Shard o ); @Override boolean equals( final Object o ); @Override int hashCode(); @Override String toString(); }
Shard implements Comparable<Shard> { @Override public int compareTo( final Shard o ) { if ( o == null ) { return 1; } if ( shardIndex > o.shardIndex ) { return 1; } else if ( shardIndex == o.shardIndex ) { if ( createdTime > o.createdTime ) { return 1; } else if ( createdTime < o.createdTime ) { return -1; } else { if ( compacted && !o.compacted ) { return 1; } else if ( !compacted && o.compacted ){ return -1; } } return 0; } return -1; } Shard( final long shardIndex, final long createdTime, final boolean compacted ); long getShardIndex(); long getCreatedTime(); boolean isCompacted(); void setCompacted(final boolean compacted); boolean isMinShard(); void setShardEnd(final Optional<DirectedEdge> shardEnd); Optional<DirectedEdge> getShardEnd(); boolean isDeleted(); void setDeleted( final boolean deleted); @Override int compareTo( final Shard o ); @Override boolean equals( final Object o ); @Override int hashCode(); @Override String toString(); static final Shard MIN_SHARD; }