- All Superinterfaces:
Comparable<HttpMediaType>,MediaType,Predicate<HttpMediaType>
public sealed interface HttpMediaType
extends Predicate<HttpMediaType>, Comparable<HttpMediaType>, MediaType
Media type used in HTTP headers, in addition to the media type definition, these may contain additional
parameters, such as
QUALITY_FACTOR_PARAMETER and CHARSET_PARAMETER.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpMediaType.Builderbuilder()A fluent API builder for creating customized Media type instances.charset()GetsOptionalvalue of charset parameter.static HttpMediaTypeCreate a new HTTP media type from media type.static HttpMediaTypeParse media type from the provided string.static HttpMediaTypecreate(String mediaTypeString, ParserMode parserMode) Parse media type from the provided string.The underlying media type.Read-only parameter map.doubleQuality factor, if not defined, defaults to 1.default Stringsubtype()Subtype, such asyaml.booleanCheck if this media type is compatible with another media type.booleantest(HttpMediaType other) Check if this media type is compatible with another media type.text()Text of this media type, to be used on the wire.default Stringtype()Type, such asapplication.default HttpMediaTypewithCharset(String charset) Create a newHttpMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter.default HttpMediaTypewithCharset(Charset charset) Create a newHttpMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter.default HttpMediaTypewithParameter(String name, String value) Create a newHttpMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied custom parameter.Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface io.helidon.common.media.type.MediaType
fullType, hasSuffix, isWildcardSubtype, isWildcardType
-
Field Details
-
CHARSET_PARAMETER
The media type "charset" parameter name.- See Also:
-
QUALITY_FACTOR_PARAMETER
The media type quality factor "q" parameter name.- See Also:
-
-
Method Details
-
builder
A fluent API builder for creating customized Media type instances.- Returns:
- a new builder
-
create
Create a new HTTP media type from media type.- Parameters:
mediaType- media type- Returns:
- a new HTTP media type without any parameters
-
create
Parse media type from the provided string. Strict media type parsing mode is used.- Parameters:
mediaTypeString- media type string- Returns:
- HTTP media type parsed from the string
-
create
Parse media type from the provided string.- Parameters:
mediaTypeString- media type stringparserMode- media type parsing mode- Returns:
- HTTP media type parsed from the string
-
mediaType
MediaType mediaType()The underlying media type.- Returns:
- media type
-
qualityFactor
double qualityFactor()Quality factor, if not defined, defaults to 1.- Returns:
- quality factor
-
parameters
Read-only parameter map. Keys are case-insensitive.- Returns:
- an immutable map of parameters.
-
charset
GetsOptionalvalue of charset parameter.- Returns:
- Charset parameter.
-
test
Check if this media type is compatible with another media type. E.g. image/* is compatible with image/jpeg, image/png, etc. Media type parameters are ignored. The function is commutative.- Specified by:
testin interfacePredicate<HttpMediaType>- Parameters:
other- the media type to compare with.- Returns:
- true if the types are compatible, false otherwise.
-
test
Check if this media type is compatible with another media type. E.g. image/* is compatible with image/jpeg, image/png, etc. Media type parameters are ignored. The function is commutative.- Parameters:
mediaType- the media type to compare with.- Returns:
- true if the types are compatible, false otherwise.
-
type
Description copied from interface:MediaTypeType, such asapplication. -
subtype
Description copied from interface:MediaTypeSubtype, such asyaml. -
withCharset
Create a newHttpMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter. -
withCharset
Create a newHttpMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter. -
text
String text()Text of this media type, to be used on the wire. -
withParameter
Create a newHttpMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied custom parameter.- Parameters:
name- name of the parametervalue- value of the parameter- Returns:
- copy of the current
MediaTypeinstance with the "charset" parameter set to the supplied value.
-