private static AbstractWebApplicationService determineWebApplicationFormat(
        final HttpServletRequest request,
        final AbstractWebApplicationService webApplicationService) {
        val format = Optional.ofNullable(request)
            .map(httpServletRequest -> httpServletRequest.getParameter(CasProtocolConstants.PARAMETER_FORMAT))
            .orElse(StringUtils.EMPTY);
        try {
            if (StringUtils.isNotBlank(format)) {
                val formatType = ValidationResponseType.valueOf(Objects.requireNonNull(format).toUpperCase(Locale.ENGLISH));
                webApplicationService.setFormat(formatType);
            }
        } catch (final Exception e) {
            LOGGER.error("Format specified in the request [{}] is not recognized", format);
        }
        return webApplicationService;
    }
The {@link WebApplicationServiceFactory} is responsible for
creating {@link WebApplicationService} objects.

@author Misagh Moayyed
@since 4.2
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/authentication/principal/WebApplicationServiceFactory.java