dajac commented on code in PR #23888:
URL: https://github.com/apache/kafka/pull/23888#discussion_r4337606282
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/share/ShareGroup.java:
##########
@@ -97,6 +105,29 @@ public record InitMapValue(
Set<Integer> partitions,
long timestamp
) {
+ public InitMapValue {
+ partitions = Collections.unmodifiableSet(partitions);
+ }
+
+ /**
+ * @param added The partitions to add.
+ * @return A copy of this value with the partitions added.
+ */
+ public InitMapValue withAddedPartitions(Collection<Integer> added) {
Review Comment:
We always use it with `Set`. I wonder if we should directly use it here too.
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/share/ShareGroup.java:
##########
@@ -97,6 +105,29 @@ public record InitMapValue(
Set<Integer> partitions,
long timestamp
) {
+ public InitMapValue {
+ partitions = Collections.unmodifiableSet(partitions);
+ }
+
+ /**
+ * @param added The partitions to add.
+ * @return A copy of this value with the partitions added.
+ */
+ public InitMapValue withAddedPartitions(Collection<Integer> added) {
Review Comment:
Do we need to unit tests those new methods?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/share/ShareGroup.java:
##########
@@ -97,6 +105,29 @@ public record InitMapValue(
Set<Integer> partitions,
long timestamp
) {
+ public InitMapValue {
+ partitions = Collections.unmodifiableSet(partitions);
+ }
+
+ /**
+ * @param added The partitions to add.
+ * @return A copy of this value with the partitions added.
+ */
+ public InitMapValue withAddedPartitions(Collection<Integer> added) {
+ Set<Integer> newPartitions = new HashSet<>(partitions);
+ newPartitions.addAll(added);
+ return new InitMapValue(name, newPartitions, timestamp);
+ }
+
+ /**
+ * @param removed The partitions to remove.
+ * @return A copy of this value with the partitions removed.
+ */
+ public InitMapValue withRemovedPartitions(Collection<Integer> removed)
{
Review Comment:
ditto.
--
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]