class SpringContentTypeUtils {


    public static String computeViewContentType(
            final IWebExchange webExchange, final String defaultContentType, final Charset defaultCharset) {<FILL_FUNCTION_BODY>}



    private SpringContentTypeUtils() {
        super();
    }




}


        if (webExchange == null) {
            throw new IllegalArgumentException("Request cannot be null");
        }


        // First we will check if there is a content type already resolved by Spring's own content negotiation
        // mechanism (see ContentNegotiatingViewResolver, which is autoconfigured in Spring Boot)
        final MediaType negotiatedMediaType = (MediaType) webExchange.getAttributeValue(View.SELECTED_CONTENT_TYPE);
        if (negotiatedMediaType != null && negotiatedMediaType.isConcrete()) {
            final Charset negotiatedCharset = negotiatedMediaType.getCharset();
            if (negotiatedCharset != null) {
                return negotiatedMediaType.toString();
            } else {
                return ContentTypeUtils.combineContentTypeAndCharset(negotiatedMediaType.toString(), defaultCharset);
            }
        }


        // We will apply the default charset here because, after all, we are in an HTTP environment, and
        // the way charset is specified in HTTP is as a parameter in the same Content-Type HTTP header.
        final String combinedContentType =
                ContentTypeUtils.combineContentTypeAndCharset(defaultContentType, defaultCharset);

        // Maybe there is no value for 'defaultValue', but anyway we might want to preserve the charset
        // from the defaultContentType into the viewName-computed one
        final Charset combinedCharset =
                ContentTypeUtils.computeCharsetFromContentType(combinedContentType);

        // If the request path offers clues on the content type that would be more appropriate (because it
        // ends in ".html", ".xml", ".js", etc.), just use it
        final String requestPathContentType =
                ContentTypeUtils.computeContentTypeForRequestPath(webExchange.getRequest().getRequestPath(), combinedCharset);
        if (requestPathContentType != null) {
            return requestPathContentType;
        }

        // No way to determine a better/more specific content-type, so just return the (adequately combined) defaults
        return combinedContentType;

    
<no_super_class>