Package com.okta.commons.http
Class MediaType
- java.lang.Object
-
- com.okta.commons.http.MimeType
-
- com.okta.commons.http.MediaType
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<MimeType>
public class MediaType extends MimeType implements java.io.Serializable
A sub-class ofMimeTypethat adds support for quality parameters as defined in the HTTP specification.- Since:
- 3.0
- Author:
- Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev, Sebastien Deleuze, Kazuki Shimizu
- See Also:
- HTTP 1.1: Semantics and Content, section 3.1.1.1, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.okta.commons.http.MimeType
MimeType.SpecificityComparator<T extends MimeType>
-
-
Field Summary
Fields Modifier and Type Field Description static MediaTypeALLPublic constant media type that includes all media ranges (i.e.static java.lang.StringALL_VALUEA String equivalent ofALL.static MediaTypeAPPLICATION_ATOM_XMLPublic constant media type forapplication/atom+xml.static java.lang.StringAPPLICATION_ATOM_XML_VALUEA String equivalent ofAPPLICATION_ATOM_XML.static MediaTypeAPPLICATION_FORM_URLENCODEDPublic constant media type forapplication/x-www-form-urlencoded.static java.lang.StringAPPLICATION_FORM_URLENCODED_VALUEA String equivalent ofAPPLICATION_FORM_URLENCODED.static MediaTypeAPPLICATION_JSONPublic constant media type forapplication/json.static MediaTypeAPPLICATION_JSON_UTF8Public constant media type forapplication/json;charset=UTF-8.static java.lang.StringAPPLICATION_JSON_UTF8_VALUEA String equivalent ofAPPLICATION_JSON_UTF8.static java.lang.StringAPPLICATION_JSON_VALUEA String equivalent ofAPPLICATION_JSON.static MediaTypeAPPLICATION_OCTET_STREAMPublic constant media type forapplication/octet-stream.static java.lang.StringAPPLICATION_OCTET_STREAM_VALUEA String equivalent ofAPPLICATION_OCTET_STREAM.static MediaTypeAPPLICATION_PDFPublic constant media type forapplication/pdf.static java.lang.StringAPPLICATION_PDF_VALUEA String equivalent ofAPPLICATION_PDF.static MediaTypeAPPLICATION_PROBLEM_JSONPublic constant media type forapplication/problem+json.static MediaTypeAPPLICATION_PROBLEM_JSON_UTF8Public constant media type forapplication/problem+json.static java.lang.StringAPPLICATION_PROBLEM_JSON_UTF8_VALUEA String equivalent ofAPPLICATION_PROBLEM_JSON_UTF8.static java.lang.StringAPPLICATION_PROBLEM_JSON_VALUEA String equivalent ofAPPLICATION_PROBLEM_JSON.static MediaTypeAPPLICATION_PROBLEM_XMLPublic constant media type forapplication/problem+xml.static java.lang.StringAPPLICATION_PROBLEM_XML_VALUEA String equivalent ofAPPLICATION_PROBLEM_XML.static MediaTypeAPPLICATION_RSS_XMLPublic constant media type forapplication/rss+xml.static java.lang.StringAPPLICATION_RSS_XML_VALUEA String equivalent ofAPPLICATION_RSS_XML.static MediaTypeAPPLICATION_STREAM_JSONPublic constant media type forapplication/stream+json.static java.lang.StringAPPLICATION_STREAM_JSON_VALUEA String equivalent ofAPPLICATION_STREAM_JSON.static MediaTypeAPPLICATION_XHTML_XMLPublic constant media type forapplication/xhtml+xml.static java.lang.StringAPPLICATION_XHTML_XML_VALUEA String equivalent ofAPPLICATION_XHTML_XML.static MediaTypeAPPLICATION_XMLPublic constant media type forapplication/xml.static java.lang.StringAPPLICATION_XML_VALUEA String equivalent ofAPPLICATION_XML.static MediaTypeIMAGE_GIFPublic constant media type forimage/gif.static java.lang.StringIMAGE_GIF_VALUEA String equivalent ofIMAGE_GIF.static MediaTypeIMAGE_JPEGPublic constant media type forimage/jpeg.static java.lang.StringIMAGE_JPEG_VALUEA String equivalent ofIMAGE_JPEG.static MediaTypeIMAGE_PNGPublic constant media type forimage/png.static java.lang.StringIMAGE_PNG_VALUEA String equivalent ofIMAGE_PNG.static MediaTypeMULTIPART_FORM_DATAPublic constant media type formultipart/form-data.static java.lang.StringMULTIPART_FORM_DATA_VALUEA String equivalent ofMULTIPART_FORM_DATA.static java.util.Comparator<MediaType>QUALITY_VALUE_COMPARATORComparator used bysortByQualityValue(List).static java.util.Comparator<MediaType>SPECIFICITY_COMPARATORComparator used bysortBySpecificity(List).static MediaTypeTEXT_EVENT_STREAMPublic constant media type fortext/event-stream.static java.lang.StringTEXT_EVENT_STREAM_VALUEA String equivalent ofTEXT_EVENT_STREAM.static MediaTypeTEXT_HTMLPublic constant media type fortext/html.static java.lang.StringTEXT_HTML_VALUEA String equivalent ofTEXT_HTML.static MediaTypeTEXT_MARKDOWNPublic constant media type fortext/markdown.static java.lang.StringTEXT_MARKDOWN_VALUEA String equivalent ofTEXT_MARKDOWN.static MediaTypeTEXT_PLAINPublic constant media type fortext/plain.static java.lang.StringTEXT_PLAIN_VALUEA String equivalent ofTEXT_PLAIN.static MediaTypeTEXT_XMLPublic constant media type fortext/xml.static java.lang.StringTEXT_XML_VALUEA String equivalent ofTEXT_XML.-
Fields inherited from class com.okta.commons.http.MimeType
WILDCARD_TYPE
-
-
Constructor Summary
Constructors Constructor Description MediaType(MediaType other, java.nio.charset.Charset charset)Copy-constructor that copies the type, subtype and parameters of the givenMediaType, and allows to set the specified character set.MediaType(MediaType other, java.util.Map<java.lang.String,java.lang.String> parameters)Copy-constructor that copies the type and subtype of the givenMediaType, and allows for different parameter.MediaType(java.lang.String type)Create a newMediaTypefor the given primary type.MediaType(java.lang.String type, java.lang.String subtype)Create a newMediaTypefor the given primary type and subtype.MediaType(java.lang.String type, java.lang.String subtype, double qualityValue)Create a newMediaTypefor the given type, subtype, and quality value.MediaType(java.lang.String type, java.lang.String subtype, java.nio.charset.Charset charset)Create a newMediaTypefor the given type, subtype, and character set.MediaType(java.lang.String type, java.lang.String subtype, java.util.Map<java.lang.String,java.lang.String> parameters)Create a newMediaTypefor the given type, subtype, and parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MediaTypeasMediaType(MimeType mimeType)Re-create the given mime type as a media type.static java.util.List<MediaType>asMediaTypes(java.util.List<MimeType> mimeTypes)Re-create the given mime types as media types.protected voidcheckParameters(java.lang.String attribute, java.lang.String value)MediaTypecopyQualityValue(MediaType mediaType)Return a replica of this instance with the quality value of the given MediaType.doublegetQualityValue()Return the quality value, as indicated by aqparameter, if any.booleanincludes(MediaType other)Indicate whether thisMediaTypeincludes the given media type.booleanisCompatibleWith(MediaType other)Indicate whether thisMediaTypeis compatible with the given media type.static MediaTypeparseMediaType(java.lang.String mediaType)Parse the given String into a singleMediaType.static java.util.List<MediaType>parseMediaTypes(java.lang.String mediaTypes)Parse the given comma-separated string into a list ofMediaTypeobjects.static java.util.List<MediaType>parseMediaTypes(java.util.List<java.lang.String> mediaTypes)Parse the given list of (potentially) comma-separated strings into a list ofMediaTypeobjects.MediaTyperemoveQualityValue()Return a replica of this instance with its quality value removed.static voidsortByQualityValue(java.util.List<MediaType> mediaTypes)Sorts the given list ofMediaTypeobjects by quality value.static voidsortBySpecificity(java.util.List<MediaType> mediaTypes)Sorts the given list ofMediaTypeobjects by specificity.static voidsortBySpecificityAndQuality(java.util.List<MediaType> mediaTypes)Sorts the given list ofMediaTypeobjects by specificity as the primary criteria and quality value the secondary.static java.lang.StringtoString(java.util.Collection<MediaType> mediaTypes)Return a string representation of the given list ofMediaTypeobjects.static MediaTypevalueOf(java.lang.String value)Parse the given String value into aMediaTypeobject, with this method name following the 'valueOf' naming convention.-
Methods inherited from class com.okta.commons.http.MimeType
appendTo, compareTo, equals, getCharset, getParameter, getParameters, getSubtype, getType, hashCode, includes, isCompatibleWith, isConcrete, isWildcardSubtype, isWildcardType, toString, unquote
-
-
-
-
Field Detail
-
ALL
public static final MediaType ALL
Public constant media type that includes all media ranges (i.e. "*/*").
-
ALL_VALUE
public static final java.lang.String ALL_VALUE
A String equivalent ofALL.- See Also:
- Constant Field Values
-
APPLICATION_ATOM_XML
public static final MediaType APPLICATION_ATOM_XML
Public constant media type forapplication/atom+xml.
-
APPLICATION_ATOM_XML_VALUE
public static final java.lang.String APPLICATION_ATOM_XML_VALUE
A String equivalent ofAPPLICATION_ATOM_XML.- See Also:
- Constant Field Values
-
APPLICATION_FORM_URLENCODED
public static final MediaType APPLICATION_FORM_URLENCODED
Public constant media type forapplication/x-www-form-urlencoded.
-
APPLICATION_FORM_URLENCODED_VALUE
public static final java.lang.String APPLICATION_FORM_URLENCODED_VALUE
A String equivalent ofAPPLICATION_FORM_URLENCODED.- See Also:
- Constant Field Values
-
APPLICATION_JSON
public static final MediaType APPLICATION_JSON
Public constant media type forapplication/json.- See Also:
APPLICATION_JSON_UTF8
-
APPLICATION_JSON_VALUE
public static final java.lang.String APPLICATION_JSON_VALUE
A String equivalent ofAPPLICATION_JSON.- See Also:
APPLICATION_JSON_UTF8_VALUE, Constant Field Values
-
APPLICATION_JSON_UTF8
public static final MediaType APPLICATION_JSON_UTF8
Public constant media type forapplication/json;charset=UTF-8.
-
APPLICATION_JSON_UTF8_VALUE
public static final java.lang.String APPLICATION_JSON_UTF8_VALUE
A String equivalent ofAPPLICATION_JSON_UTF8.- See Also:
- Constant Field Values
-
APPLICATION_OCTET_STREAM
public static final MediaType APPLICATION_OCTET_STREAM
Public constant media type forapplication/octet-stream.
-
APPLICATION_OCTET_STREAM_VALUE
public static final java.lang.String APPLICATION_OCTET_STREAM_VALUE
A String equivalent ofAPPLICATION_OCTET_STREAM.- See Also:
- Constant Field Values
-
APPLICATION_PDF
public static final MediaType APPLICATION_PDF
Public constant media type forapplication/pdf.- Since:
- 4.3
-
APPLICATION_PDF_VALUE
public static final java.lang.String APPLICATION_PDF_VALUE
A String equivalent ofAPPLICATION_PDF.- Since:
- 4.3
- See Also:
- Constant Field Values
-
APPLICATION_PROBLEM_JSON
public static final MediaType APPLICATION_PROBLEM_JSON
Public constant media type forapplication/problem+json.- Since:
- 5.0
- See Also:
- Problem Details for HTTP APIs, 6.1. application/problem+json
-
APPLICATION_PROBLEM_JSON_VALUE
public static final java.lang.String APPLICATION_PROBLEM_JSON_VALUE
A String equivalent ofAPPLICATION_PROBLEM_JSON.- Since:
- 5.0
- See Also:
- Constant Field Values
-
APPLICATION_PROBLEM_JSON_UTF8
public static final MediaType APPLICATION_PROBLEM_JSON_UTF8
Public constant media type forapplication/problem+json.- Since:
- 5.0
- See Also:
- Problem Details for HTTP APIs, 6.1. application/problem+json
-
APPLICATION_PROBLEM_JSON_UTF8_VALUE
public static final java.lang.String APPLICATION_PROBLEM_JSON_UTF8_VALUE
A String equivalent ofAPPLICATION_PROBLEM_JSON_UTF8.- Since:
- 5.0
- See Also:
- Constant Field Values
-
APPLICATION_PROBLEM_XML
public static final MediaType APPLICATION_PROBLEM_XML
Public constant media type forapplication/problem+xml.- Since:
- 5.0
- See Also:
- Problem Details for HTTP APIs, 6.2. application/problem+xml
-
APPLICATION_PROBLEM_XML_VALUE
public static final java.lang.String APPLICATION_PROBLEM_XML_VALUE
A String equivalent ofAPPLICATION_PROBLEM_XML.- Since:
- 5.0
- See Also:
- Constant Field Values
-
APPLICATION_RSS_XML
public static final MediaType APPLICATION_RSS_XML
Public constant media type forapplication/rss+xml.- Since:
- 4.3.6
-
APPLICATION_RSS_XML_VALUE
public static final java.lang.String APPLICATION_RSS_XML_VALUE
A String equivalent ofAPPLICATION_RSS_XML.- Since:
- 4.3.6
- See Also:
- Constant Field Values
-
APPLICATION_STREAM_JSON
public static final MediaType APPLICATION_STREAM_JSON
Public constant media type forapplication/stream+json.- Since:
- 5.0
-
APPLICATION_STREAM_JSON_VALUE
public static final java.lang.String APPLICATION_STREAM_JSON_VALUE
A String equivalent ofAPPLICATION_STREAM_JSON.- Since:
- 5.0
- See Also:
- Constant Field Values
-
APPLICATION_XHTML_XML
public static final MediaType APPLICATION_XHTML_XML
Public constant media type forapplication/xhtml+xml.
-
APPLICATION_XHTML_XML_VALUE
public static final java.lang.String APPLICATION_XHTML_XML_VALUE
A String equivalent ofAPPLICATION_XHTML_XML.- See Also:
- Constant Field Values
-
APPLICATION_XML
public static final MediaType APPLICATION_XML
Public constant media type forapplication/xml.
-
APPLICATION_XML_VALUE
public static final java.lang.String APPLICATION_XML_VALUE
A String equivalent ofAPPLICATION_XML.- See Also:
- Constant Field Values
-
IMAGE_GIF
public static final MediaType IMAGE_GIF
Public constant media type forimage/gif.
-
IMAGE_GIF_VALUE
public static final java.lang.String IMAGE_GIF_VALUE
A String equivalent ofIMAGE_GIF.- See Also:
- Constant Field Values
-
IMAGE_JPEG
public static final MediaType IMAGE_JPEG
Public constant media type forimage/jpeg.
-
IMAGE_JPEG_VALUE
public static final java.lang.String IMAGE_JPEG_VALUE
A String equivalent ofIMAGE_JPEG.- See Also:
- Constant Field Values
-
IMAGE_PNG
public static final MediaType IMAGE_PNG
Public constant media type forimage/png.
-
IMAGE_PNG_VALUE
public static final java.lang.String IMAGE_PNG_VALUE
A String equivalent ofIMAGE_PNG.- See Also:
- Constant Field Values
-
MULTIPART_FORM_DATA
public static final MediaType MULTIPART_FORM_DATA
Public constant media type formultipart/form-data.
-
MULTIPART_FORM_DATA_VALUE
public static final java.lang.String MULTIPART_FORM_DATA_VALUE
A String equivalent ofMULTIPART_FORM_DATA.- See Also:
- Constant Field Values
-
TEXT_EVENT_STREAM
public static final MediaType TEXT_EVENT_STREAM
Public constant media type fortext/event-stream.- Since:
- 4.3.6
- See Also:
- Server-Sent Events W3C recommendation
-
TEXT_EVENT_STREAM_VALUE
public static final java.lang.String TEXT_EVENT_STREAM_VALUE
A String equivalent ofTEXT_EVENT_STREAM.- Since:
- 4.3.6
- See Also:
- Constant Field Values
-
TEXT_HTML
public static final MediaType TEXT_HTML
Public constant media type fortext/html.
-
TEXT_HTML_VALUE
public static final java.lang.String TEXT_HTML_VALUE
A String equivalent ofTEXT_HTML.- See Also:
- Constant Field Values
-
TEXT_MARKDOWN
public static final MediaType TEXT_MARKDOWN
Public constant media type fortext/markdown.- Since:
- 4.3
-
TEXT_MARKDOWN_VALUE
public static final java.lang.String TEXT_MARKDOWN_VALUE
A String equivalent ofTEXT_MARKDOWN.- Since:
- 4.3
- See Also:
- Constant Field Values
-
TEXT_PLAIN
public static final MediaType TEXT_PLAIN
Public constant media type fortext/plain.
-
TEXT_PLAIN_VALUE
public static final java.lang.String TEXT_PLAIN_VALUE
A String equivalent ofTEXT_PLAIN.- See Also:
- Constant Field Values
-
TEXT_XML
public static final MediaType TEXT_XML
Public constant media type fortext/xml.
-
TEXT_XML_VALUE
public static final java.lang.String TEXT_XML_VALUE
A String equivalent ofTEXT_XML.- See Also:
- Constant Field Values
-
QUALITY_VALUE_COMPARATOR
public static final java.util.Comparator<MediaType> QUALITY_VALUE_COMPARATOR
Comparator used bysortByQualityValue(List).
-
SPECIFICITY_COMPARATOR
public static final java.util.Comparator<MediaType> SPECIFICITY_COMPARATOR
Comparator used bysortBySpecificity(List).
-
-
Constructor Detail
-
MediaType
public MediaType(java.lang.String type)
Create a newMediaTypefor the given primary type.The subtype is set to "*", parameters empty.
- Parameters:
type- the primary type- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters
-
MediaType
public MediaType(java.lang.String type, java.lang.String subtype)Create a newMediaTypefor the given primary type and subtype.The parameters are empty.
- Parameters:
type- the primary typesubtype- the subtype- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters
-
MediaType
public MediaType(java.lang.String type, java.lang.String subtype, java.nio.charset.Charset charset)Create a newMediaTypefor the given type, subtype, and character set.- Parameters:
type- the primary typesubtype- the subtypecharset- the character set- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters
-
MediaType
public MediaType(java.lang.String type, java.lang.String subtype, double qualityValue)Create a newMediaTypefor the given type, subtype, and quality value.- Parameters:
type- the primary typesubtype- the subtypequalityValue- the quality value- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters
-
MediaType
public MediaType(MediaType other, java.nio.charset.Charset charset)
Copy-constructor that copies the type, subtype and parameters of the givenMediaType, and allows to set the specified character set.- Parameters:
other- the other media typecharset- the character set- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters- Since:
- 4.3
-
MediaType
public MediaType(MediaType other, java.util.Map<java.lang.String,java.lang.String> parameters)
Copy-constructor that copies the type and subtype of the givenMediaType, and allows for different parameter.- Parameters:
other- the other media typeparameters- the parameters, may benull- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters
-
MediaType
public MediaType(java.lang.String type, java.lang.String subtype, java.util.Map<java.lang.String,java.lang.String> parameters)Create a newMediaTypefor the given type, subtype, and parameters.- Parameters:
type- the primary typesubtype- the subtypeparameters- the parameters, may benull- Throws:
java.lang.IllegalArgumentException- if any of the parameters contain illegal characters
-
-
Method Detail
-
checkParameters
protected void checkParameters(java.lang.String attribute, java.lang.String value)- Overrides:
checkParametersin classMimeType
-
getQualityValue
public double getQualityValue()
Return the quality value, as indicated by aqparameter, if any. Defaults to1.0.- Returns:
- the quality factory
-
includes
public boolean includes(MediaType other)
Indicate whether thisMediaTypeincludes the given media type.For instance,
text/*includestext/plainandtext/html, andapplication/*+xmlincludesapplication/soap+xml, etc. This method is not symmetric.- Parameters:
other- the reference media type with which to compare- Returns:
trueif this media type includes the given media type;falseotherwise
-
isCompatibleWith
public boolean isCompatibleWith(MediaType other)
Indicate whether thisMediaTypeis compatible with the given media type.For instance,
text/*is compatible withtext/plain,text/html, and vice versa. In effect, this method is similar toincludes(MediaType), except that it is symmetric.- Parameters:
other- the reference media type with which to compare- Returns:
trueif this media type is compatible with the given media type;falseotherwise
-
copyQualityValue
public MediaType copyQualityValue(MediaType mediaType)
Return a replica of this instance with the quality value of the given MediaType.- Returns:
- the same instance if the given MediaType doesn't have a quality value, or a new one otherwise
-
removeQualityValue
public MediaType removeQualityValue()
Return a replica of this instance with its quality value removed.- Returns:
- the same instance if the media type doesn't contain a quality value, or a new one otherwise
-
valueOf
public static MediaType valueOf(java.lang.String value)
Parse the given String value into aMediaTypeobject, with this method name following the 'valueOf' naming convention.- Parameters:
value- the string to parse- Throws:
InvalidMediaTypeException- if the media type value cannot be parsed- See Also:
parseMediaType(String)
-
parseMediaType
public static MediaType parseMediaType(java.lang.String mediaType)
Parse the given String into a singleMediaType.- Parameters:
mediaType- the string to parse- Returns:
- the media type
- Throws:
InvalidMediaTypeException- if the media type value cannot be parsed
-
parseMediaTypes
public static java.util.List<MediaType> parseMediaTypes(java.lang.String mediaTypes)
Parse the given comma-separated string into a list ofMediaTypeobjects.This method can be used to parse an Accept or Content-Type header.
- Parameters:
mediaTypes- the string to parse- Returns:
- the list of media types
- Throws:
InvalidMediaTypeException- if the media type value cannot be parsed
-
parseMediaTypes
public static java.util.List<MediaType> parseMediaTypes(java.util.List<java.lang.String> mediaTypes)
Parse the given list of (potentially) comma-separated strings into a list ofMediaTypeobjects.This method can be used to parse an Accept or Content-Type header.
- Parameters:
mediaTypes- the string to parse- Returns:
- the list of media types
- Throws:
InvalidMediaTypeException- if the media type value cannot be parsed- Since:
- 4.3.2
-
asMediaTypes
public static java.util.List<MediaType> asMediaTypes(java.util.List<MimeType> mimeTypes)
Re-create the given mime types as media types.- Since:
- 5.0
-
asMediaType
public static MediaType asMediaType(MimeType mimeType)
Re-create the given mime type as a media type.- Since:
- 5.0
-
toString
public static java.lang.String toString(java.util.Collection<MediaType> mediaTypes)
Return a string representation of the given list ofMediaTypeobjects.This method can be used to for an
AcceptorContent-Typeheader.- Parameters:
mediaTypes- the media types to create a string representation for- Returns:
- the string representation
-
sortBySpecificity
public static void sortBySpecificity(java.util.List<MediaType> mediaTypes)
Sorts the given list ofMediaTypeobjects by specificity.Given two media types:
- if either media type has a wildcard type, then the media type without the wildcard is ordered before the other.
- if the two media types have different types, then they are considered equal and remain their current order.
- if either media type has a wildcard subtype, then the media type without the wildcard is sorted before the other.
- if the two media types have different subtypes, then they are considered equal and remain their current order.
- if the two media types have different quality value, then the media type with the highest quality value is ordered before the other.
- if the two media types have a different amount of parameters, then the media type with the most parameters is ordered before the other.
For example:
audio/basic < audio/* < */*
audio/* < audio/*;q=0.7; audio/*;q=0.3
audio/basic;level=1 < audio/basic
audio/basic == text/html
audio/basic == audio/wave
- Parameters:
mediaTypes- the list of media types to be sorted- See Also:
- HTTP 1.1: Semantics and Content, section 5.3.2
-
sortByQualityValue
public static void sortByQualityValue(java.util.List<MediaType> mediaTypes)
Sorts the given list ofMediaTypeobjects by quality value.Given two media types:
- if the two media types have different quality value, then the media type with the highest quality value is ordered before the other.
- if either media type has a wildcard type, then the media type without the wildcard is ordered before the other.
- if the two media types have different types, then they are considered equal and remain their current order.
- if either media type has a wildcard subtype, then the media type without the wildcard is sorted before the other.
- if the two media types have different subtypes, then they are considered equal and remain their current order.
- if the two media types have a different amount of parameters, then the media type with the most parameters is ordered before the other.
- Parameters:
mediaTypes- the list of media types to be sorted- See Also:
getQualityValue()
-
sortBySpecificityAndQuality
public static void sortBySpecificityAndQuality(java.util.List<MediaType> mediaTypes)
Sorts the given list ofMediaTypeobjects by specificity as the primary criteria and quality value the secondary.- See Also:
sortBySpecificity(List),sortByQualityValue(List)
-
-