public abstract class AbstractMappingContentNegotiationStrategy extends MappingMediaTypeFileExtensionResolver implements ContentNegotiationStrategy, MediaTypeFileExtensionResolver
Constructor and Description |
---|
AbstractMappingContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
Create an instance with the given extension-to-MediaType lookup.
|
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getMediaTypeKey(NativeWebRequest request)
Sub-classes must extract the key to use to look up a media type.
|
protected void |
handleMatch(String mappingKey,
MediaType mediaType)
Invoked when a matching media type is found in the lookup map.
|
protected MediaType |
handleNoMatch(NativeWebRequest request,
String mappingKey)
Invoked when no matching media type is found in the lookup map.
|
List<MediaType> |
resolveMediaTypes(NativeWebRequest webRequest)
Resolve the given request to a list of media types.
|
addMapping, getAllFileExtensions, lookupMediaType, resolveFileExtensions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllFileExtensions, resolveFileExtensions
public AbstractMappingContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
IllegalArgumentException
- if a media type string cannot be parsedpublic List<MediaType> resolveMediaTypes(NativeWebRequest webRequest)
ContentNegotiationStrategy
resolveMediaTypes
in interface ContentNegotiationStrategy
webRequest
- the current requestnull
protected abstract String getMediaTypeKey(NativeWebRequest request)
null
if the key cannot be derivedprotected void handleMatch(String mappingKey, MediaType mediaType)
protected MediaType handleNoMatch(NativeWebRequest request, String mappingKey)