Package org.springframework.web.accept

# Class FixedContentNegotiationStrategy

java.lang.Object
org.springframework.web.accept.FixedContentNegotiationStrategy

All Implemented Interfaces:
  `ContentNegotiationStrategy`

public class FixedContentNegotiationStrategy extends Object implements ContentNegotiationStrategy
A `ContentNegotiationStrategy` that returns a fixed content type.

Since:
  3.2
Author:
  Rossen Stoyanchev

## Field Summary

### Fields inherited from interface org.springframework.web.accept.ContentNegotiationStrategy

`MEDIA_TYPE_ALL_LIST`

## Constructor Summary

Constructors
Constructor
Description
`FixedContentNegotiationStrategy(List<MediaType> contentTypes)`
Constructor with an ordered List of default `MediaType`'s to return for use in applications that support a variety of content types.
`FixedContentNegotiationStrategy(MediaType contentType)`
Constructor with a single default `MediaType`.

## Method Summary

Modifier and Type
Method
Description
`List<MediaType>`
`getContentTypes()`
Return the configured list of media types.
`List<MediaType>`
`resolveMediaTypes(NativeWebRequest request)`
Resolve the given request to a list of media types.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FixedContentNegotiationStrategy

public FixedContentNegotiationStrategy(MediaType contentType)
Constructor with a single default `MediaType`.

### FixedContentNegotiationStrategy

public FixedContentNegotiationStrategy(List<MediaType> contentTypes)
Constructor with an ordered List of default `MediaType`'s to return for use in applications that support a variety of content types.

Consider appending `MediaType.ALL` at the end if destinations are present which do not support any of the other default media types.

Since:
  5.0

## Method Details

### getContentTypes

public List<MediaType> getContentTypes()
Return the configured list of media types.

### resolveMediaTypes

public List<MediaType> resolveMediaTypes(NativeWebRequest request)
Description copied from interface: `ContentNegotiationStrategy`
Resolve the given request to a list of media types. The returned list is ordered by specificity first and by quality parameter second.

Specified by:
  `resolveMediaTypes` in interface `ContentNegotiationStrategy`
Parameters:
  `request` - the current request
Returns:
  the requested media types, or `ContentNegotiationStrategy.MEDIA_TYPE_ALL_LIST` if none were requested.