public boolean isBeforeOrAt(KinesisRecord other) {
    if (shardIteratorType == AT_TIMESTAMP) {
      return timestamp.compareTo(other.getApproximateArrivalTimestamp()) <= 0;
    }
    int result = extendedSequenceNumber().compareTo(other.getExtendedSequenceNumber());
    if (result == 0) {
      return shardIteratorType == AT_SEQUENCE_NUMBER;
    }
    return result < 0;
  }
@Test
  public void testComparisonWithExtendedSequenceNumber() {
    assertThat(
            new ShardCheckpoint("", "", new StartingPoint(LATEST))
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L))))
        .isTrue();

    assertThat(
            new ShardCheckpoint("", "", new StartingPoint(TRIM_HORIZON))
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L))))
        .isTrue();

    assertThat(
            checkpoint(AFTER_SEQUENCE_NUMBER, "10", 1L)
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L))))
        .isTrue();

    assertThat(
            checkpoint(AT_SEQUENCE_NUMBER, "100", 0L)
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L))))
        .isTrue();

    assertThat(
            checkpoint(AFTER_SEQUENCE_NUMBER, "100", 0L)
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L))))
        .isFalse();

    assertThat(
            checkpoint(AT_SEQUENCE_NUMBER, "100", 1L)
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L))))
        .isFalse();

    assertThat(
            checkpoint(AFTER_SEQUENCE_NUMBER, "100", 0L)
                .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("99", 1L))))
        .isFalse();
  }