static String replicaMoveStatesToString(Map<TopicPartitionReplica, LogDirMoveState> states) {
        List<String> bld = new ArrayList<>();
        states.keySet().stream().sorted(ReassignPartitionsCommand::compareTopicPartitionReplicas).forEach(replica -> {
            LogDirMoveState state = states.get(replica);
            if (state instanceof MissingLogDirMoveState) {
                bld.add("Partition " + replica.topic() + "-" + replica.partition() + " is not found " +
                    "in any live log dir on broker " + replica.brokerId() + ". There is likely an " +
                    "offline log directory on the broker.");
            } else if (state instanceof MissingReplicaMoveState) {
                bld.add("Partition " + replica.topic() + "-" + replica.partition() + " cannot be found " +
                    "in any live log directory on broker " + replica.brokerId() + ".");
            } else if (state instanceof ActiveMoveState) {
                String targetLogDir = ((ActiveMoveState) state).targetLogDir;
                String futureLogDir = ((ActiveMoveState) state).futureLogDir;
                if (targetLogDir.equals(futureLogDir)) {
                    bld.add("Reassignment of replica " + replica + " is still in progress.");
                } else {
                    bld.add("Partition " + replica.topic() + "-" + replica.partition() + " on broker " +
                        replica.brokerId() + " is being moved to log dir " + futureLogDir + " " +
                        "instead of " + targetLogDir + ".");
                }
            } else if (state instanceof CancelledMoveState) {
                String targetLogDir = ((CancelledMoveState) state).targetLogDir;
                String currentLogDir = ((CancelledMoveState) state).currentLogDir;
                bld.add("Partition " + replica.topic() + "-" + replica.partition() + " on broker " +
                    replica.brokerId() + " is not being moved from log dir " + currentLogDir + " to " +
                    targetLogDir + ".");
            } else if (state instanceof CompletedMoveState) {
                bld.add("Reassignment of replica " + replica + " completed successfully.");
            }
        });

        return bld.stream().collect(Collectors.joining(System.lineSeparator()));
    }
Convert replica move states to a human-readable string.

@param states          A map from topic partition replicas to states.
@return                A tuple of a summary string, and a boolean describing
                       whether there are any active replica moves.
tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java