private static void addAuthTypesToConnectionProvidersResponseDTO( ConnectionProvider connectionProvider, ConnectionProviderResponseDTO providerDTO) { // TODO: (@W) This needs some serious refactoring List<AuthTypeResponseDTO> authTypeResponseDTOList = new ArrayList<>(); for (AuthType supportedAuthType : connectionProvider.getSupportedAuthTypes()) { AuthTypeResponseDTO.Builder authTypeDTOBuilder = new AuthTypeResponseDTO.Builder(); authTypeDTOBuilder.type(supportedAuthType.toString()); if (supportedAuthType.equals(AuthType.USERNAME_PASSWORD)) { authTypeDTOBuilder.usernameLabel(connectionProvider.getUsernameLabel()); authTypeDTOBuilder.passwordLabel(connectionProvider.getPasswordLabel()); } if (supportedAuthType.equals(AuthType.OAUTH)) { authTypeDTOBuilder.oauthEndpoint( String.format(OAUTH_ENDPOINT_PATTERN, connectionProvider.getId())); authTypeDTOBuilder.commandLabel("Connect to " + connectionProvider.getDisplayName()); } authTypeResponseDTOList.add(authTypeDTOBuilder.build()); } AuthTypeResponsesDTO authTypeResponsesDTO = new AuthTypeResponsesDTO(); authTypeResponsesDTO.setAuthTypes(authTypeResponseDTOList); providerDTO.authTypes = authTypeResponsesDTO; }