|
31 | 31 | import com.datastax.oss.driver.api.core.time.TimestampGenerator; |
32 | 32 | import com.datastax.oss.driver.api.core.type.reflect.GenericType; |
33 | 33 | import com.datastax.oss.driver.internal.core.util.RoutingKey; |
| 34 | +import com.datastax.oss.protocol.internal.request.query.QueryOptions; |
34 | 35 | import edu.umd.cs.findbugs.annotations.CheckReturnValue; |
35 | 36 | import edu.umd.cs.findbugs.annotations.NonNull; |
36 | 37 | import edu.umd.cs.findbugs.annotations.Nullable; |
@@ -67,6 +68,13 @@ public interface Statement<SelfT extends Statement<SelfT>> extends Request { |
67 | 68 | GenericType<CompletionStage<AsyncResultSet>> ASYNC = |
68 | 69 | new GenericType<CompletionStage<AsyncResultSet>>() {}; |
69 | 70 |
|
| 71 | + /** |
| 72 | + * A special value for {@link #getNowInSeconds()} that means "no value". |
| 73 | + * |
| 74 | + * <p>It is equal to {@link Integer#MIN_VALUE}. |
| 75 | + */ |
| 76 | + int NO_NOW_IN_SECONDS = QueryOptions.NO_NOW_IN_SECONDS; |
| 77 | + |
70 | 78 | /** |
71 | 79 | * Sets the name of the execution profile that will be used for this statement. |
72 | 80 | * |
@@ -348,6 +356,34 @@ default SelfT setRoutingKey(@NonNull ByteBuffer... newRoutingKeyComponents) { |
348 | 356 | /** Whether tracing information should be recorded for this statement. */ |
349 | 357 | boolean isTracing(); |
350 | 358 |
|
| 359 | + /** |
| 360 | + * A custom "now in seconds" to use when applying the request (for testing purposes). |
| 361 | + * |
| 362 | + * <p>This method's default implementation returns {@link #NO_NOW_IN_SECONDS}. The only reason it |
| 363 | + * exists is to preserve binary compatibility. Internally, the driver overrides it to return the |
| 364 | + * value that was set programmatically (if any). |
| 365 | + * |
| 366 | + * @see #NO_NOW_IN_SECONDS |
| 367 | + */ |
| 368 | + default int getNowInSeconds() { |
| 369 | + return NO_NOW_IN_SECONDS; |
| 370 | + } |
| 371 | + |
| 372 | + /** |
| 373 | + * Sets the "now in seconds" to use when applying the request (for testing purposes). |
| 374 | + * |
| 375 | + * <p>This method's default implementation returns the statement unchanged. The only reason it |
| 376 | + * exists is to preserve binary compatibility. Internally, the driver overrides it to record the |
| 377 | + * new value. |
| 378 | + * |
| 379 | + * @see #NO_NOW_IN_SECONDS |
| 380 | + */ |
| 381 | + @NonNull |
| 382 | + @SuppressWarnings("unchecked") |
| 383 | + default SelfT setNowInSeconds(int nowInSeconds) { |
| 384 | + return (SelfT) this; |
| 385 | + } |
| 386 | + |
351 | 387 | /** |
352 | 388 | * Calculates the approximate size in bytes that the statement will have when encoded. |
353 | 389 | * |
|
0 commit comments