AndrewJSchofield commented on code in PR #17626:
URL: https://github.com/apache/kafka/pull/17626#discussion_r1823444073


##########
clients/src/main/java/org/apache/kafka/clients/admin/GroupListing.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.clients.admin;
+
+import org.apache.kafka.common.GroupType;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * A listing of a group in the cluster.
+ */
+public class GroupListing {
+    private final String groupId;
+    private final Optional<GroupType> type;
+    private final String protocol;
+
+    /**
+     * Create an instance with the specified parameters.
+     *
+     * @param groupId Group Id
+     * @param type Group type
+     * @param protocol Protocol
+     */
+    public GroupListing(String groupId, Optional<GroupType> type, String 
protocol) {
+        this.groupId = groupId;
+        this.type = Objects.requireNonNull(type);
+        this.protocol = protocol;
+    }
+
+    /**
+     * The group Id.
+     *
+     * @return Group Id
+     */
+    public String groupId() {
+        return groupId;
+    }
+
+    /**
+     * The type of the group.
+     *
+     * @return An Optional containing the type, if available
+     */
+    public Optional<GroupType> type() {
+        return type;
+    }
+
+    /**
+     * The protocol of the group.
+     *
+     * @return The protocol
+     */
+    public String protocol() {
+        return protocol;
+    }
+
+    /**
+     * If the group is a simple consumer group or not.
+     */
+    public boolean isSimpleConsumerGroup() {
+        return type.filter(gt -> gt == GroupType.CLASSIC).isPresent() && 
protocol.isEmpty();
+    }
+
+    @Override
+    public String toString() {
+        return "(" +
+            "groupId='" + groupId + '\'' +
+            ", type=" + type +
+            ", protocol=" + protocol +
+            ')';
+    }
+
+    protected String toStringBase() {

Review Comment:
   Ah, good catch. I previously had a subclass of this class.



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