Package software.amazon.smithy.utils
Class MediaType
java.lang.Object
software.amazon.smithy.utils.MediaType
Implements a simple media type parser based on the Content-Type grammar defined in
 RFC 7231.
 
The type, subtype, and parameter names are all canonicalized to lowercase strings.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanstatic MediaTypeCreate a parsed MediaType from the given string.Gets the immutable map of parameters.Gets the "subtype" of the media type.Gets the "subtype" of the media type with no structured syntax suffix.Gets the optional structured syntax suffix.getType()Gets the "type" of the media type.inthashCode()static booleanDetects if the given media type string is JSON, meaning it is "application/json" or uses the "+json" structured syntax suffix.toString()
- 
Method Details- 
fromCreate a parsed MediaType from the given string.- Parameters:
- value- Media type to parse (e.g., application/json).
- Returns:
- Returns the parsed media type.
- Throws:
- RuntimeException- if the media type is invalid.
 
- 
isJsonDetects if the given media type string is JSON, meaning it is "application/json" or uses the "+json" structured syntax suffix.- Parameters:
- mediaType- Media type to parse and test if it's JSON.
- Returns:
- Returns true if the given media type is JSON.
 
- 
getTypeGets the "type" of the media type.- Returns:
- Returns the type (e.g., "application").
 
- 
getSubtypeGets the "subtype" of the media type.- Returns:
- Returns the subtype (e.g., "json", "foo+json").
 
- 
getSubtypeWithoutSuffixGets the "subtype" of the media type with no structured syntax suffix.For example given, "application/foo+json", this method returns "foo". Given "application/foo+baz+json", this method returns "foo+baz". - Returns:
- Returns the subtype (e.g., "json", "foo+json").
 
- 
getParametersGets the immutable map of parameters.- Returns:
- Returns the parameters.
 
- 
getSuffixGets the optional structured syntax suffix.For example given, "application/foo+json", this method returns "json". Given "application/foo+baz+json", this method returns "json". Given "application/json", this method returns an empty Optional.- Returns:
- Returns the optional structured syntax suffix value with no "+".
 
- 
toString
- 
equals
- 
hashCodepublic int hashCode()
 
-