public static Entry<Map<TopicPartition, List<Integer>>, Map<TopicPartition, List<Integer>>> generateAssignment(Admin adminClient,
                                                                                                             String reassignmentJson,
                                                                                                             String brokerListString,
                                                                                                             Boolean enableRackAwareness
    ) throws ExecutionException, InterruptedException, JsonProcessingException {
        Entry<List<Integer>, List<String>> t0 = parseGenerateAssignmentArgs(reassignmentJson, brokerListString);

        List<Integer> brokersToReassign = t0.getKey();
        List<String> topicsToReassign = t0.getValue();

        Map<TopicPartition, List<Integer>> currentAssignments = getReplicaAssignmentForTopics(adminClient, topicsToReassign);
        List<BrokerMetadata> brokerMetadatas = getBrokerMetadata(adminClient, brokersToReassign, enableRackAwareness);
        Map<TopicPartition, List<Integer>> proposedAssignments = calculateAssignment(currentAssignments, brokerMetadatas);
        System.out.printf("Current partition replica assignment%n%s%n%n",
            formatAsReassignmentJson(currentAssignments, Collections.emptyMap()));
        System.out.printf("Proposed partition reassignment configuration%n%s%n",
            formatAsReassignmentJson(proposedAssignments, Collections.emptyMap()));
        return new SimpleImmutableEntry<>(proposedAssignments, currentAssignments);
    }
The entry point for the --generate command.

@param adminClient           The AdminClient to use.
@param reassignmentJson      The JSON string to use for the topics to reassign.
@param brokerListString      The comma-separated string of broker IDs to use.
@param enableRackAwareness   True if rack-awareness should be enabled.

@return                      A tuple containing the proposed assignment and the
                             current assignment.
tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java