public static MediaType convertMediaType()

in dubbo-rpc-extensions/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/util/MediaTypeUtil.java [36:56]


    public static MediaType convertMediaType(Class<?> targetType, String... contentTypes) {

        if (contentTypes == null || contentTypes.length == 0) {
            return HttpMessageCodecManager.typeSupport(targetType);
        }

        for (String contentType : contentTypes) {
            for (MediaType mediaType : mediaTypes) {

                if (contentType != null && contentType.contains(mediaType.value)) {
                    return mediaType;
                }
            }

            if (contentType != null && contentType.contains(MediaType.ALL_VALUE.value)) {
                return HttpMessageCodecManager.typeSupport(targetType);
            }
        }

        throw new UnSupportContentTypeException(Arrays.toString(contentTypes));
    }