chenjunjiedada commented on code in PR #7362:
URL: https://github.com/apache/iceberg/pull/7362#discussion_r1189745123
##########
flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/source/ScanContext.java:
##########
@@ -149,12 +152,26 @@ private void validate() {
}
Preconditions.checkArgument(
- !(startTag != null && startSnapshotId() != null),
- "START_SNAPSHOT_ID and START_TAG cannot both be set.");
+ atMostOneNonNull(startSnapshotId(), startTag,
startSnapshotTimestamp()),
+ "Cannot specify more than one of start-snapshot-id, start-tag, or
start-snapshot-timestamp.");
Preconditions.checkArgument(
- !(endTag != null && endSnapshotId() != null),
- "END_SNAPSHOT_ID and END_TAG cannot both be set.");
+ atMostOneNonNull(endSnapshotId(), endTag, endSnapshotTimestamp()),
+ "Cannot specify more than one of end-snapshot-id, end-tag, or
end-snapshot-timestamp.");
+ }
+
+ private static boolean atMostOneNonNull(Object... objects) {
+ int count = 0;
+ for (Object obj : objects) {
+ if (obj != null) {
+ count++;
+ }
+
+ if (count > 1) {
+ return false;
+ }
+ }
+ return true;
Review Comment:
nit: blank line after block.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]