- 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
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpMediaType.Builder
builder()
A fluent API builder for creating customized Media type instances.charset()
GetsOptional
value of charset parameter.static HttpMediaType
Create a new HTTP media type from media type.static HttpMediaType
Parse media type from the provided string.static HttpMediaType
create
(String mediaTypeString, ParserMode parserMode) Parse media type from the provided string.The underlying media type.Read-only parameter map.double
Quality factor, if not defined, defaults to 1.default String
subtype()
Subtype, such asyaml
.boolean
Check if this media type is compatible with another media type.boolean
test
(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 String
type()
Type, such asapplication
.default HttpMediaType
withCharset
(String charset) Create a newHttpMediaType
instance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter.default HttpMediaType
withCharset
(Charset charset) Create a newHttpMediaType
instance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter.default HttpMediaType
withParameter
(String name, String value) Create a newHttpMediaType
instance with the same type, subtype and parameters copied from the original instance and the supplied custom parameter.Methods inherited from interface java.lang.Comparable
compareTo
Methods 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
GetsOptional
value 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:
test
in 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:MediaType
Type, such asapplication
. -
subtype
Description copied from interface:MediaType
Subtype, such asyaml
. -
withCharset
Create a newHttpMediaType
instance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter. -
withCharset
Create a newHttpMediaType
instance 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 newHttpMediaType
instance 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
MediaType
instance with the "charset" parameter set to the supplied value.
-