Class ValidatorMediaTypeUtil


  • public final class ValidatorMediaTypeUtil
    extends Object
    Utility class to deal with MediaTypes in JAX-RS endpoints.
    • Method Detail

      • getAcceptMediaTypeFromSupported

        public static javax.ws.rs.core.MediaType getAcceptMediaTypeFromSupported​(List<javax.ws.rs.core.MediaType> mediaTypesFromRequest)
        Look up the right media type taking into account the HTTP request and the supported media types.
        Parameters:
        mediaTypesFromRequest - list of media types in the HTTP request.
        Returns:
        one supported media type from either the HTTP request or the annotation.
      • getAcceptMediaType

        public static javax.ws.rs.core.MediaType getAcceptMediaType​(List<javax.ws.rs.core.MediaType> mediaTypesFromRequest,
                                                                    List<javax.ws.rs.core.MediaType> mediaTypesFromProducesAnnotation)
        Look up the right media type taking into account the HTTP request and the media types defined in the `@Produces` annotation.
        Parameters:
        mediaTypesFromRequest - list of media types in the HTTP request.
        mediaTypesFromProducesAnnotation - list of media types set in the `@Produces` annotation.
        Returns:
        one supported media type from either the HTTP request or the annotation.