Introduce addSupportedMediaType() in FormHttpMessageConverter

Closes gh-23203
This commit is contained in:
Sam Brannen
2019-06-27 16:00:02 +03:00
parent 8e1cb9a059
commit 4e7d8a8873
2 changed files with 51 additions and 14 deletions

View File

@@ -88,6 +88,7 @@ import org.springframework.util.StringUtils;
* @author Arjen Poutsma
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.0
* @see org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
* @see org.springframework.util.MultiValueMap
@@ -127,9 +128,23 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
/**
* Set the list of {@link MediaType} objects supported by this converter.
* @see #addSupportedMediaType(MediaType)
* @see #getSupportedMediaTypes()
*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
this.supportedMediaTypes = supportedMediaTypes;
Assert.notNull(supportedMediaTypes, "'supportedMediaTypes' must not be null");
// Ensure internal list is mutable.
this.supportedMediaTypes = new ArrayList<>(supportedMediaTypes);
}
/**
* Add a {@link MediaType} to be supported by this converter.
* @since 5.2
* @see #setSupportedMediaTypes(List)
*/
public void addSupportedMediaType(MediaType supportedMediaType) {
Assert.notNull(supportedMediaType, "'supportedMediaType' must not be null");
this.supportedMediaTypes.add(supportedMediaType);
}
@Override