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, MediaSupport
- Direct Known Subclasses:
JacksonSupport, JsonBindingSupport, JsonbSupport, JsonpSupport, JsonSupport, SmileSupport
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 MediaSupport
MediaSupport.ReaderResponse<T>, MediaSupport.SupportLevel, MediaSupport.WriterResponse<T>Modifier and TypeInterfaceDescriptionstatic final recordReader response.static enumHow does this provider support the entity type.static final recordWriter response. -
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(Config, String).type()Type of this implementation, to distinguish instances of same type, with differentNamedService.name().Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MediaSupport
init, reader, reader, writer, writerModifier and TypeMethodDescriptiondefault voidinit(MediaContext context) Once all providers are discovered/configured and context is established, theMediaContextcalls this method on all providers to allow sub-resolution of readers and writers.default <T> MediaSupport.ReaderResponse<T> reader(GenericType<T> type, Headers headers) Reader for an entity.default <T> MediaSupport.ReaderResponse<T> reader(GenericType<T> type, Headers requestHeaders, Headers responseHeaders) Client response reader.default <T> MediaSupport.WriterResponse<T> writer(GenericType<T> type, Headers requestHeaders, WritableHeaders<?> responseHeaders) Server response writer.default <T> MediaSupport.WriterResponse<T> writer(GenericType<T> type, WritableHeaders<?> requestHeaders) Client request writer.
-
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(Config, String).- 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- 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
-