public abstract class AbstractMappingContentTypeResolver extends Object implements MappingContentTypeResolver
MappingContentTypeResolver implementations.
Maintains the actual mappings and pre-implements the overall algorithm with
sub-classes left to provide a way to extract the lookup key (e.g. file
extension, query parameter, etc) for a given exchange.| Constructor and Description |
|---|
AbstractMappingContentTypeResolver(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract String |
extractKey(ServerWebExchange exchange)
Extract the key to use to look up a media type from the given exchange,
e.g.
|
Set<String> |
getKeys()
Return all registered keys (e.g.
|
Set<String> |
getKeysFor(MediaType mediaType)
Resolve the given media type to a list of path extensions.
|
protected MediaType |
getMediaType(String key)
Sub-classes can use this method to look up a MediaType by key.
|
protected List<MediaType> |
getMediaTypes()
Sub-classes can use this method get all mapped media types.
|
protected void |
handleMatch(String key,
MediaType mediaType)
Override to provide handling when a key is successfully resolved via
getMediaType(String). |
protected MediaType |
handleNoMatch(String key)
Override to provide handling when a key is not resolved via.
|
List<MediaType> |
resolveMediaTypes(ServerWebExchange exchange)
Resolve the given request to a list of requested media types.
|
List<MediaType> |
resolveMediaTypes(String key)
An overloaded resolve method with a pre-resolved lookup key.
|
protected MediaType getMediaType(String key)
key - the key converted to lower casenullprotected List<MediaType> getMediaTypes()
public List<MediaType> resolveMediaTypes(ServerWebExchange exchange) throws NotAcceptableStatusException
RequestedContentTypeResolverresolveMediaTypes in interface RequestedContentTypeResolverexchange - the current exchangeNotAcceptableStatusException - if the requested media types is invalidpublic List<MediaType> resolveMediaTypes(String key) throws NotAcceptableStatusException
key - the key for looking up media typesNotAcceptableStatusExceptionprotected abstract String extractKey(ServerWebExchange exchange)
nullprotected void handleMatch(String key, MediaType mediaType)
getMediaType(String).protected MediaType handleNoMatch(String key) throws NotAcceptableStatusException
getMediaType(String). If a MediaType is returned from
this method it will be added to the mappings.NotAcceptableStatusExceptionpublic Set<String> getKeysFor(MediaType mediaType)
MappingContentTypeResolvergetKeysFor in interface MappingContentTypeResolvermediaType - the media type to resolvenullpublic Set<String> getKeys()
MappingContentTypeResolvergetKeys in interface MappingContentTypeResolvernull