File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
main/java/org/springframework/http/converter
test/java/org/springframework/http/converter Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -138,13 +138,20 @@ public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
138
138
}
139
139
140
140
/**
141
- * Add a {@link MediaType} to be supported by this converter.
141
+ * Add {@link MediaType} objects to be supported by this converter.
142
+ * <p>The supplied {@code MediaType} objects will be appended to the list
143
+ * of {@linkplain #getSupportedMediaTypes() supported MediaType objects}.
144
+ * @param supportedMediaTypes a var-args list of {@code MediaType} objects
145
+ * to add
142
146
* @since 5.2
143
147
* @see #setSupportedMediaTypes(List)
144
148
*/
145
- public void addSupportedMediaType (MediaType supportedMediaType ) {
146
- Assert .notNull (supportedMediaType , "'supportedMediaType' must not be null" );
147
- this .supportedMediaTypes .add (supportedMediaType );
149
+ public void addSupportedMediaTypes (MediaType ... supportedMediaTypes ) {
150
+ Assert .notNull (supportedMediaTypes , "'supportedMediaTypes' must not be null" );
151
+ Assert .noNullElements (supportedMediaTypes , "'supportedMediaTypes' must not contain null elements" );
152
+ for (MediaType mediaType : supportedMediaTypes ) {
153
+ this .supportedMediaTypes .add (mediaType );
154
+ }
148
155
}
149
156
150
157
@ Override
Original file line number Diff line number Diff line change @@ -93,12 +93,11 @@ public void setSupportedMediaTypes() {
93
93
}
94
94
95
95
@ Test
96
- public void addSupportedMediaType () {
96
+ public void addSupportedMediaTypes () {
97
97
assertCannotWrite (MULTIPART_MIXED );
98
98
assertCannotWrite (MULTIPART_RELATED );
99
99
100
- this .converter .addSupportedMediaType (MULTIPART_MIXED );
101
- this .converter .addSupportedMediaType (MULTIPART_RELATED );
100
+ this .converter .addSupportedMediaTypes (MULTIPART_MIXED , MULTIPART_RELATED );
102
101
103
102
assertCanWrite (MULTIPART_MIXED );
104
103
assertCanWrite (MULTIPART_RELATED );
You can’t perform that action at this time.
0 commit comments