PartitionKey implements Comparable<PartitionKey> { @Override public int compareTo(final PartitionKey other) { if (other instanceof NegativeInfinityPartitionKey) { return 1; } if (other instanceof PositiveInfinityPartitionKey) { return -1; } if (this.partitionKey.length != other.partitionKey.length) { throw new RuntimeException("Arrays should be of equal length: this.partitionKey.length = " + this.partitionKey.length + ", other.partitionKey.length = " + other.partitionKey.length); } for (int i = 0; i < this.partitionKey.length; i++) { final int diff = ((Comparable) this.partitionKey[i]).compareTo((Comparable) other.partitionKey[i]); if (0 != diff) { return diff; } } return 0; } PartitionKey(final Object[] partitionKey); Object[] getPartitionKey(); int getLength(); @Override String toString(); @Override int compareTo(final PartitionKey other); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void testCompare() { final PartitionKey[] partitionKeys = new PartitionKey[6]; partitionKeys[0] = new PartitionKey(new Object[]{1L, 50, "A"}); partitionKeys[1] = new PartitionKey(new Object[]{1L, 50, "B"}); partitionKeys[2] = new PartitionKey(new Object[]{1L, 500, "A"}); partitionKeys[3] = new PartitionKey(new Object[]{1L, 500, "B"}); partitionKeys[4] = new PartitionKey(new Object[]{1L, 5000, "A"}); partitionKeys[5] = new PartitionKey(new Object[]{10L, 5000, "A"}); for (int i = 1; i < partitionKeys.length; i++) { assertTrue(partitionKeys[i - 1].compareTo(partitionKeys[i]) < 0); } }