@Override
  public boolean tryClaim(Timestamp position) {
    checkArgument(
        lastAttemptedPosition == null || position.compareTo(lastAttemptedPosition) > 0,
        "Trying to claim offset %s while last attempted was %s",
        position,
        lastAttemptedPosition);
    checkArgument(
        position.compareTo(range.getFrom()) >= 0,
        "Trying to claim offset %s before start of the range %s",
        position,
        range);
    lastAttemptedPosition = position;

    // It is ok to try to claim offsets beyond of the range, this will simply return false
    if (position.compareTo(range.getTo()) >= 0) {
      return false;
    }
    lastClaimedPosition = position;
    return true;
  }
@Test
  public void testTryClaimFailsWhenPositionIsLessThanTheBeginningOfTheRange() {
    final Timestamp from = Timestamp.ofTimeMicroseconds(5L);
    final Timestamp to = Timestamp.ofTimeMicroseconds(10L);
    final Timestamp position = Timestamp.ofTimeMicroseconds(4L);
    final TimestampRange range = TimestampRange.of(from, to);
    final TimestampRangeTracker tracker = new TimestampRangeTracker(range);

    assertThrows(IllegalArgumentException.class, () -> tracker.tryClaim(position));
  }