Chia-Ping Tsai created KAFKA-21150:
--------------------------------------

             Summary: Refactor AbstractKafkaConfig#processRoles
                 Key: KAFKA-21150
                 URL: https://issues.apache.org/jira/browse/KAFKA-21150
             Project: Kafka
          Issue Type: Improvement
            Reporter: Chia-Ping Tsai
            Assignee: Chia-Ping Tsai


 
{code:java}
    public Set<ProcessRole> processRoles() {
        Set<ProcessRole> result = new HashSet<>();
        for (String role : getList(KRaftConfigs.PROCESS_ROLES_CONFIG)) {
            switch (role) {
                case "broker" -> result.add(ProcessRole.BrokerRole);
                case "controller" -> result.add(ProcessRole.ControllerRole);
                default -> throw new ConfigException("Unknown process role '" + 
role +
                            "' (only 'broker' and 'controller' are allowed 
roles)");
            }
        }
        return Collections.unmodifiableSet(result);
    } {code}
We could add a helper method to {{ProcessRole}} that converts a string to a 
{{{}ProcessRole{}}}, and then rewrite {{processRoles()}} in a fluent style.

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to