Package org.bremersee.http
Class MediaTypeHelper
- java.lang.Object
-
- org.bremersee.http.MediaTypeHelper
-
@Validated public abstract class MediaTypeHelper extends Object
The media type helper.- Author:
- Christian Bremer
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
canContentTypeBeJson(String mediaType)
Determine whether the given media type can be rendered as json.static boolean
canContentTypeBeXml(String mediaType)
Determine whether the given media type can be rendered as xml.static org.springframework.http.MediaType
findContentType(List<org.springframework.http.MediaType> accepts, org.springframework.http.MediaType fallback)
Determine the content type from the given accepts header.static boolean
isAll(String mediaType)
Determine whether the given content type is all.static boolean
isJson(String mediaType)
Determine whether the given content type is json.static boolean
isText(String mediaType)
Determine whether the given content type is text.static boolean
isXml(String mediaType)
Determine whether the given content type is xml.static String
toString(List<org.springframework.http.MediaType> mediaTypes)
Creates a header value of the given media types.
-
-
-
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 headerfallback
- the content type when no one could be found- Returns:
- the content type
-
-