jsancio commented on code in PR #13788:
URL: https://github.com/apache/kafka/pull/13788#discussion_r1213240584


##########
metadata/src/main/java/org/apache/kafka/metadata/PartitionRegistration.java:
##########
@@ -33,6 +33,92 @@
 
 
 public class PartitionRegistration {
+
+    /**
+     * A builder class which creates a PartitionRegistration.
+     */
+    static public class Builder {
+        private int[] replicas;
+        private int[] isr;
+        private int[] removingReplicas = Replicas.NONE;
+        private int[] addingReplicas = Replicas.NONE;
+        private Integer leader;
+        private LeaderRecoveryState leaderRecoveryState;
+        private Integer leaderEpoch;
+        private Integer partitionEpoch;
+
+        public Builder setReplicas(int[] replicas) {
+            this.replicas = replicas;
+            return this;
+        }
+
+        public Builder setIsr(int[] isr) {
+            this.isr = isr;
+            return this;
+        }
+
+        public Builder setRemovingReplicas(int[] removingReplicas) {
+            this.removingReplicas = removingReplicas;
+            return this;
+        }
+
+        public Builder setAddingReplicas(int[] addingReplicas) {
+            this.addingReplicas = addingReplicas;
+            return this;
+        }
+
+        public Builder setLeader(Integer leader) {
+            this.leader = leader;
+            return this;
+        }
+
+        public Builder setLeaderRecoveryState(LeaderRecoveryState 
leaderRecoveryState) {
+            this.leaderRecoveryState = leaderRecoveryState;
+            return this;
+        }
+
+        public Builder setLeaderEpoch(Integer leaderEpoch) {
+            this.leaderEpoch = leaderEpoch;
+            return this;
+        }
+
+        public Builder setPartitionEpoch(Integer partitionEpoch) {
+            this.partitionEpoch = partitionEpoch;
+            return this;
+        }
+
+        public PartitionRegistration build() {
+            if (replicas == null) {
+                throw new IllegalStateException("You must set replicas.");
+            } else if (isr == null) {
+                throw new IllegalStateException("You must set isr.");
+            } else if (removingReplicas == null) {
+                throw new IllegalStateException("You must set removing 
replicas.");
+            } else if (addingReplicas == null) {
+                throw new IllegalStateException("You must set adding 
replicas.");
+            } else if (leader == null) {
+                throw new IllegalStateException("You must set leader.");
+            } else if (leaderRecoveryState == null) {
+                throw new IllegalStateException("You must set leader recovery 
state.");

Review Comment:
   I should have mentioned in my previous review but how about having a default 
of this state too? The default should be `RECOVERED`.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to