/** Specifies the function to use to assign timestamps to the elements. */ public GenerateSequence withTimestampFn(SerializableFunction<Long, Instant> timestampFn) { return toBuilder().setTimestampFn(timestampFn).build(); }
/** Specifies to stop generating elements after the given time. */ public GenerateSequence withMaxReadTime(Duration maxReadTime) { return toBuilder().setMaxReadTime(maxReadTime).build(); }
/** Specifies to generate at most a given number of elements per a given period. */ public GenerateSequence withRate(long numElements, Duration periodLength) { checkArgument( numElements > 0, "Number of elements in withRate must be positive, but was: %s", numElements); checkArgument(periodLength != null, "periodLength can not be null"); return toBuilder().setElementsPerPeriod(numElements).setPeriod(periodLength).build(); }
/** Specifies the maximum number to generate (exclusive). */ public GenerateSequence to(long to) { checkArgument( getTo() == -1 || getTo() >= getFrom(), "Degenerate range [%s, %s)", getFrom(), getTo()); return toBuilder().setTo(to).build(); }