private String formUsernameFromParam()

in sdk/src/main/java/software/amazon/awssdk/iot/AwsIotMqtt5ClientBuilder.java [810:850]


    private String formUsernameFromParam(List<String> paramList) throws Exception {
        boolean firstAddition = true;
        boolean useAmp = false;
        String result = "";

        // If there are no params, end early
        if (paramList.size() == 0) {
            return result;
        }

        // We only allow pairs, so make sure it is even
        if (paramList.size() % 2 != 0) {
            throw new Exception("Username parameters are not an even number!");
        }

        for (int i = 0; i < paramList.size(); i++) {
            String key = paramList.get(i);
            String value = paramList.get(i+1);

            if (firstAddition == true) {
                firstAddition = false;
            } else {
                if (useAmp == false) {
                    result += "?";
                    useAmp = true;
                } else {
                    result += "&";
                }
            }

            if (key != null && value != null) {
                result += key + "=" + value;
            } else if (value != null) {
                // Needed for the initial username and other value-only items
                result += value;
            }

            i = i+1;
        }
        return result;
    }