public static ClassicGroup fromConsumerGroup(
        ConsumerGroup consumerGroup,
        String leavingMemberId,
        LogContext logContext,
        Time time,
        GroupCoordinatorMetricsShard metrics,
        MetadataImage metadataImage
    ) {
        ClassicGroup classicGroup = new ClassicGroup(
            logContext,
            consumerGroup.groupId(),
            ClassicGroupState.STABLE,
            time,
            metrics,
            consumerGroup.groupEpoch(),
            Optional.ofNullable(ConsumerProtocol.PROTOCOL_TYPE),
            Optional.empty(),
            Optional.empty(),
            Optional.of(time.milliseconds())
        );

        consumerGroup.members().forEach((memberId, member) -> {
            if (!memberId.equals(leavingMemberId)) {
                classicGroup.add(
                    new ClassicGroupMember(
                        memberId,
                        Optional.ofNullable(member.instanceId()),
                        member.clientId(),
                        member.clientHost(),
                        member.rebalanceTimeoutMs(),
                        member.classicProtocolSessionTimeout().get(),
                        ConsumerProtocol.PROTOCOL_TYPE,
                        member.supportedJoinGroupRequestProtocols(),
                        null
                    )
                );
            }
        });

        classicGroup.setProtocolName(Optional.of(classicGroup.selectProtocol()));
        classicGroup.setSubscribedTopics(classicGroup.computeSubscribedTopics());

        classicGroup.allMembers().forEach(classicGroupMember -> {
            // Set the assignment with serializing the ConsumerGroup's targetAssignment.
            // The serializing version should align with that of the member's JoinGroupRequestProtocol.
            byte[] assignment = Utils.toArray(ConsumerProtocol.serializeAssignment(
                toConsumerProtocolAssignment(
                    consumerGroup.targetAssignment().get(classicGroupMember.memberId()).partitions(),
                    metadataImage.topics()
                ),
                ConsumerProtocol.deserializeVersion(
                    ByteBuffer.wrap(classicGroupMember.metadata(classicGroup.protocolName().orElse("")))
                )
            ));

            classicGroupMember.setAssignment(assignment);
        });

        return classicGroup;
    }
Convert the given ConsumerGroup to a corresponding ClassicGroup.
The member with leavingMemberId will not be converted to the new ClassicGroup as it's the last
member using new consumer protocol that left and triggered the downgrade.

@param consumerGroup                 The converted ConsumerGroup.
@param leavingMemberId               The member that will not be converted in the ClassicGroup.
@param logContext                    The logContext to create the ClassicGroup.
@param time                          The time to create the ClassicGroup.
@param metadataImage                 The MetadataImage.
@return  The created ClassicGroup.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java