From 60fac678844a5626f4f5c7150a648b981c4ce427 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 13 May 2020 21:59:16 +0200 Subject: [PATCH] Polish --- .../java/org/springframework/http/MediaType.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index af3c9f9f9d..012279c12e 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -370,7 +370,6 @@ public class MediaType extends MimeType implements Serializable { private static final String PARAM_QUALITY_FACTOR = "q"; - static { // Not using "valueOf' to avoid static init cost ALL = new MediaType("*", "*"); @@ -401,7 +400,6 @@ public class MediaType extends MimeType implements Serializable { TEXT_XML = new MediaType("text", "xml"); } - /** * Create a new {@code MediaType} for the given primary type. *

The {@linkplain #getSubtype() subtype} is set to "*", parameters empty. @@ -479,6 +477,14 @@ public class MediaType extends MimeType implements Serializable { super(type, subtype, parameters); } + /** + * Create a new {@code MediaType} for the given {@link MimeType}. + * The type, subtype and parameters information is copied and {@code MediaType}-specific + * checks on parameters are performed. + * @param mimeType the MIME type + * @throws IllegalArgumentException if any of the parameters contain illegal characters + * @since 5.3.0 + */ public MediaType(MimeType mimeType) { super(mimeType); this.getParameters().forEach(this::checkParameters); @@ -653,7 +659,7 @@ public class MediaType extends MimeType implements Serializable { */ public static List asMediaTypes(List mimeTypes) { List mediaTypes = new ArrayList<>(mimeTypes.size()); - for(MimeType mimeType : mimeTypes) { + for (MimeType mimeType : mimeTypes) { mediaTypes.add(MediaType.asMediaType(mimeType)); } return mediaTypes;