Polishing
Closes gh-29768
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,15 +63,13 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter
|
||||
|
||||
/**
|
||||
* Constructor with a single MIME type.
|
||||
* @param supportedMimeType the supported MIME type
|
||||
*/
|
||||
protected AbstractMessageConverter(MimeType supportedMimeType) {
|
||||
this(Collections.singletonList(supportedMimeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with one or more MIME types via vararg.
|
||||
* @param supportedMimeTypes the supported MIME types
|
||||
* Constructor with multiple MIME types.
|
||||
* @since 5.2.2
|
||||
*/
|
||||
protected AbstractMessageConverter(MimeType... supportedMimeTypes) {
|
||||
@@ -79,8 +77,7 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with a Collection of MIME types.
|
||||
* @param supportedMimeTypes the supported MIME types
|
||||
* Constructor with Collection of MIME types.
|
||||
*/
|
||||
protected AbstractMessageConverter(Collection<MimeType> supportedMimeTypes) {
|
||||
this.supportedMimeTypes.addAll(supportedMimeTypes);
|
||||
@@ -103,20 +100,21 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the {@link ContentTypeResolver} to use to resolve the content
|
||||
* type of an input message.
|
||||
* <p>Note that if no resolver is configured, then
|
||||
* {@link #setStrictContentTypeMatch(boolean) strictContentTypeMatch} should
|
||||
* be left as {@code false} (the default) or otherwise this converter will
|
||||
* ignore all messages.
|
||||
* Configure a {@link ContentTypeResolver} for resolving the content type
|
||||
* of input messages.
|
||||
* <p>By default, a {@code DefaultContentTypeResolver} instance is used.
|
||||
* <p><strong>Note:</strong> if the resolver is set to {@code null}, then
|
||||
* {@link #setStrictContentTypeMatch(boolean) strictContentTypeMatch} should
|
||||
* be {@code false}, which is the default, or otherwise this converter will
|
||||
* ignore all messages.
|
||||
*/
|
||||
public void setContentTypeResolver(@Nullable ContentTypeResolver resolver) {
|
||||
this.contentTypeResolver = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configured {@link ContentTypeResolver}.
|
||||
* Return the {@link #setContentTypeResolver(ContentTypeResolver) configured}
|
||||
* {@code ContentTypeResolver}.
|
||||
*/
|
||||
@Nullable
|
||||
public ContentTypeResolver getContentTypeResolver() {
|
||||
@@ -125,11 +123,11 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter
|
||||
|
||||
/**
|
||||
* Whether this converter should convert messages for which no content type
|
||||
* could be resolved through the configured
|
||||
* can be resolved through the configured
|
||||
* {@link org.springframework.messaging.converter.ContentTypeResolver}.
|
||||
* <p>A converter can be configured to be strict only when a
|
||||
* {@link #setContentTypeResolver contentTypeResolver} is configured and the
|
||||
* list of {@link #getSupportedMimeTypes() supportedMimeTypes} is not be empty.
|
||||
* list of {@link #getSupportedMimeTypes() supportedMimeTypes} is not empty.
|
||||
* <p>When this flag is set to {@code true}, {@link #supportsMimeType(MessageHeaders)}
|
||||
* will return {@code false} if the {@link #setContentTypeResolver contentTypeResolver}
|
||||
* is not defined or if no content-type header is present.
|
||||
@@ -193,7 +191,9 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
|
||||
public final Message<?> toMessage(
|
||||
Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
|
||||
|
||||
if (!canConvertTo(payload, headers)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user