static String partitionReassignmentStatesToString(Map<TopicPartition, PartitionReassignmentState> states) {
        List<String> bld = new ArrayList<>();
        bld.add("Status of partition reassignment:");
        states.keySet().stream().sorted(ReassignPartitionsCommand::compareTopicPartitions).forEach(topicPartition -> {
            PartitionReassignmentState state = states.get(topicPartition);
            if (state.done) {
                if (state.currentReplicas.equals(state.targetReplicas)) {
                    bld.add(String.format("Reassignment of partition %s is completed.", topicPartition));
                } else {
                    String currentReplicaStr = state.currentReplicas.stream().map(String::valueOf).collect(Collectors.joining(","));
                    String targetReplicaStr = state.targetReplicas.stream().map(String::valueOf).collect(Collectors.joining(","));

                    bld.add("There is no active reassignment of partition " + topicPartition + ", " +
                        "but replica set is " + currentReplicaStr + " rather than " +
                        targetReplicaStr + ".");
                }
            } else {
                bld.add(String.format("Reassignment of partition %s is still in progress.", topicPartition));
            }
        });
        return bld.stream().collect(Collectors.joining(System.lineSeparator()));
    }
Convert partition reassignment states to a human-readable string.

@param states      A map from topic partitions to states.
@return            A string summarizing the partition reassignment states.
tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java