Class MediaTypeHelper


  • @Validated
    public abstract class MediaTypeHelper
    extends Object
    The media type helper.
    Author:
    Christian Bremer
    • Method Detail

      • canContentTypeBeJson

        public static boolean canContentTypeBeJson​(@Nullable
                                                   String mediaType)
        Determine whether the given media type can be rendered as json.
        Parameters:
        mediaType - the media type
        Returns:
        the boolean
      • canContentTypeBeXml

        public static boolean canContentTypeBeXml​(@Nullable
                                                  String mediaType)
        Determine whether the given media type can be rendered as xml.
        Parameters:
        mediaType - the media type
        Returns:
        the boolean
      • isJson

        public static boolean isJson​(@Nullable
                                     String mediaType)
        Determine whether the given content type is json.
        Parameters:
        mediaType - the media type
        Returns:
        the boolean
      • isText

        public static boolean isText​(@Nullable
                                     String mediaType)
        Determine whether the given content type is text.
        Parameters:
        mediaType - the media type
        Returns:
        the boolean
      • isAll

        public static boolean isAll​(@Nullable
                                    String mediaType)
        Determine whether the given content type is all.
        Parameters:
        mediaType - the media type
        Returns:
        the boolean
      • isXml

        public static boolean isXml​(@Nullable
                                    String mediaType)
        Determine whether the given content type is xml.
        Parameters:
        mediaType - the media type
        Returns:
        the boolean
      • toString

        @Nullable
        public static String toString​(@Nullable
                                      List<org.springframework.http.MediaType> mediaTypes)
        Creates a header value of the given media types.
        Parameters:
        mediaTypes - the media types
        Returns:
        the header value
      • findContentType

        @Nullable
        public static org.springframework.http.MediaType findContentType​(@Nullable
                                                                         List<org.springframework.http.MediaType> accepts,
                                                                         @Nullable
                                                                         org.springframework.http.MediaType fallback)
        Determine the content type from the given accepts header.
        Parameters:
        accepts - the accepts header
        fallback - the content type when no one could be found
        Returns:
        the content type