Browse Source

PR comments fx

iliax 2 years ago
parent
commit
68ee46d789

+ 5 - 1
kafka-ui-api/src/main/java/com/provectus/kafka/ui/model/ConsumerPosition.java

@@ -1,5 +1,6 @@
 package com.provectus.kafka.ui.model;
 package com.provectus.kafka.ui.model;
 
 
+import com.google.common.base.Preconditions;
 import com.provectus.kafka.ui.exception.ValidationException;
 import com.provectus.kafka.ui.exception.ValidationException;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -14,9 +15,12 @@ public record ConsumerPosition(PollingModeDTO pollingMode,
                                @Nullable Long timestamp,
                                @Nullable Long timestamp,
                                @Nullable Offsets offsets) {
                                @Nullable Offsets offsets) {
 
 
-  // one of properties will be null
   public record Offsets(@Nullable Long offset, //should be applied to all partitions
   public record Offsets(@Nullable Long offset, //should be applied to all partitions
                         @Nullable Map<TopicPartition, Long> tpOffsets) {
                         @Nullable Map<TopicPartition, Long> tpOffsets) {
+    public Offsets {
+      // only one of properties should be set
+      Preconditions.checkArgument((offset == null && tpOffsets != null) || (offset != null && tpOffsets == null));
+    }
   }
   }
 
 
   public static ConsumerPosition create(PollingModeDTO pollingMode,
   public static ConsumerPosition create(PollingModeDTO pollingMode,