Module io.helidon.http.media
Package io.helidon.http.media
Class MediaSupportBase<T extends MediaSupportConfig>
java.lang.Object
io.helidon.http.media.MediaSupportBase<T>
- Type Parameters:
T- the configuration object used by the subtype, must extendMediaSupportConfig
- All Implemented Interfaces:
NamedService,NamedService,MediaSupport
- Direct Known Subclasses:
GsonSupport,JacksonSupport,JsonBindingSupport,JsonbSupport,JsonpSupport,JsonSupport
public abstract class MediaSupportBase<T extends MediaSupportConfig>
extends Object
implements MediaSupport
A base class that can be used to implement media support that has a few common features,
such as support for
MediaSupportConfig.
This base class provides checks for all four methods (client request, client response, server request, server response) and makes sure that the type is supported, and that media types match.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.helidon.http.media.MediaSupport
MediaSupport.ReaderResponse<T>, MediaSupport.SupportLevel, MediaSupport.WriterResponse<T> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMediaSupportBase(T config, String type) Construct a new support base for the specified type. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancanDeserialize(GenericType<?> type) Check whether the type is supported by this media support for deserialization.protected abstract booleancanSerialize(GenericType<?> type) Check whether the type is supported by this media support for serialization.protected Tconfig()The configuration object used to create this instance.protected booleanisMediaTypeSupported(HttpMediaType mediaType) Check whether the provided media type is one of the supported media types.protected booleanmatchesClientRequest(GenericType<?> type, Headers requestHeaders) Client request writer check.protected booleanmatchesClientResponse(GenericType<?> type, Headers responseHeaders) Client response reader check.protected booleanmatchesServerRequest(GenericType<?> type, Headers requestHeaders) Server request reader check.protected booleanmatchesServerResponse(GenericType<?> type, Headers requestHeaders, Headers responseHeaders) Server response writer check.name()Name of this implementation, as provided inConfiguredProvider.create(io.helidon.common.config.Config, String).type()Type of this implementation, to distinguish instances of same type, with differentNamedService.name().
-
Constructor Details
-
MediaSupportBase
Construct a new support base for the specified type.- Parameters:
config- aMediaSupportConfigsubtype to configure this instancetype- type of the media support, such asjson-binding
-
-
Method Details
-
name
Description copied from interface:NamedServiceName of this implementation, as provided inConfiguredProvider.create(io.helidon.common.config.Config, String).- Specified by:
namein interfaceNamedService- Specified by:
namein interfaceNamedService- Returns:
- name of this service
-
type
Description copied from interface:NamedServiceType of this implementation, to distinguish instances of same type, with differentNamedService.name(). Use for exampleConfiguredProvider.configKey()to define the type.- Specified by:
typein interfaceNamedService- Specified by:
typein interfaceNamedService- Returns:
- type of this service
-
matchesServerRequest
Server request reader check.- Parameters:
type- requested typerequestHeaders- server request headers- Returns:
- whether we support this request and can provide a reader
-
matchesServerResponse
protected boolean matchesServerResponse(GenericType<?> type, Headers requestHeaders, Headers responseHeaders) Server response writer check. Checks our content type against theAcceptheader of the request.- Parameters:
type- provided typerequestHeaders- server request headersresponseHeaders- server response headers- Returns:
- whether we support this response and can provide a writer
-
matchesClientRequest
Client request writer check. Checks if the content type and type is supported.- Parameters:
type- provided typerequestHeaders- client request headers- Returns:
- whether we support this request and can provide a writer
-
matchesClientResponse
Client response reader check. Checks if the content type and type is supported.- Parameters:
type- requested typeresponseHeaders- client response headers- Returns:
- whether we support this response and can provide a reader
-
isMediaTypeSupported
Check whether the provided media type is one of the supported media types.- Parameters:
mediaType- media type to check- Returns:
- whether it is a supported media type
-
config
The configuration object used to create this instance.- Returns:
- the config object
-
canSerialize
Check whether the type is supported by this media support for serialization.- Parameters:
type- type to check- Returns:
- whether this media support can handle this type
-
canDeserialize
Check whether the type is supported by this media support for deserialization.- Parameters:
type- type to check- Returns:
- whether this media support can handle this type
-