@Override
        public AlterPartitionRequest build(short version) {
            if (version < 3) {
                data.topics().forEach(topicData ->
                    topicData.partitions().forEach(partitionData -> {
                        // The newIsrWithEpochs will be empty after build. Then we can skip the conversion if the build
                        // is called again.
                        if (!partitionData.newIsrWithEpochs().isEmpty()) {
                            List<Integer> newIsr = new ArrayList<>(partitionData.newIsrWithEpochs().size());
                            partitionData.newIsrWithEpochs().forEach(brokerState ->
                                newIsr.add(brokerState.brokerId())
                            );
                            partitionData.setNewIsr(newIsr);
                            partitionData.setNewIsrWithEpochs(Collections.emptyList());
                        }
                    })
                );
            }
            return new AlterPartitionRequest(data, version);
        }
Constructs a builder for AlterPartitionRequest.

@param data The data to be sent. Note that because the version of the
            request is not known at this time, it is expected that all
            topics have a topic id and a topic name set.
@param canUseTopicIds True if version 2 and above can be used.
clients/src/main/java/org/apache/kafka/common/requests/AlterPartitionRequest.java