dajac commented on code in PR #18020:
URL: https://github.com/apache/kafka/pull/18020#discussion_r1872742423


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/SubscriptionCount.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.modern;
+
+/**
+ * A class which holds two counters. One to count subscription by name and
+ * another one to count subscription by regex.
+ */
+public class SubscriptionCount {
+    public final int byNameCount;
+    public final int byRegexCount;
+
+    public SubscriptionCount(int byNameCount, int byRegexCount) {
+        this.byNameCount = byNameCount;
+        this.byRegexCount = byRegexCount;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SubscriptionCount that = (SubscriptionCount) o;
+
+        if (byNameCount != that.byNameCount) return false;
+        return byRegexCount == that.byRegexCount;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = byNameCount;
+        result = 31 * result + byRegexCount;
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "SubscriptionCount(" +
+            "byNameCount=" + byNameCount +
+            ", byRegexCount=" + byRegexCount +
+            ')';
+    }
+
+    public static SubscriptionCount incNameCount(String key, SubscriptionCount 
count) {

Review Comment:
   we only use those helpers with `Map#compute` and it does provide the `key`. 
we could remove them but it would be less convenient on the other side. i 
prefer to keep them.



-- 
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