diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java index 4234df9f31c..4090982ae65 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java @@ -47,6 +47,7 @@ import org.springframework.web.server.ServerWebExchange; * Base class for {@link View} implementations. * * @author Rossen Stoyanchev + * @author Sam Brannen * @since 5.0 */ public abstract class AbstractView implements View, BeanNameAware, ApplicationContextAware { @@ -86,7 +87,7 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo /** * Set the supported media types for this view. - * Default is "text/html;charset=UTF-8". + *

Default is {@code "text/html;charset=UTF-8"}. */ public void setSupportedMediaTypes(List supportedMediaTypes) { Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty"); @@ -95,7 +96,7 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Return the configured media types supported by this view. + * Get the configured media types supported by this view. */ @Override public List getSupportedMediaTypes() { @@ -105,7 +106,7 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo /** * Set the default charset for this view, used when the * {@linkplain #setSupportedMediaTypes(List) content type} does not contain one. - * Default is {@linkplain StandardCharsets#UTF_8 UTF 8}. + *

Default is {@linkplain StandardCharsets#UTF_8 UTF 8}. */ public void setDefaultCharset(Charset defaultCharset) { Assert.notNull(defaultCharset, "'defaultCharset' must not be null"); @@ -113,7 +114,7 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Return the default charset, used when the + * Get the default charset, used when the * {@linkplain #setSupportedMediaTypes(List) content type} does not contain one. */ public Charset getDefaultCharset() { @@ -121,15 +122,15 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Set the name of the RequestContext attribute for this view. - * Default is none. + * Set the name of the {@code RequestContext} attribute for this view. + *

Default is none ({@code null}). */ public void setRequestContextAttribute(@Nullable String requestContextAttribute) { this.requestContextAttribute = requestContextAttribute; } /** - * Return the name of the RequestContext attribute, if any. + * Get the name of the {@code RequestContext} attribute for this view, if any. */ @Nullable public String getRequestContextAttribute() { @@ -146,8 +147,8 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Return the view's name. Should never be {@code null}, if the view was - * correctly configured. + * Get the view's name. + *

Should never be {@code null} if the view was correctly configured. */ @Nullable public String getBeanName() { @@ -165,9 +166,10 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Obtain the ApplicationContext for actual use. - * @return the ApplicationContext (never {@code null}) - * @throws IllegalStateException in case of no ApplicationContext set + * Obtain the {@link ApplicationContext} for actual use. + * @return the {@code ApplicationContext} (never {@code null}) + * @throws IllegalStateException if the ApplicationContext cannot be obtained + * @see #getApplicationContext() */ protected final ApplicationContext obtainApplicationContext() { ApplicationContext applicationContext = getApplicationContext(); @@ -178,12 +180,12 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo /** * Prepare the model to render. - * @param model a Map with name Strings as keys and corresponding model - * objects as values (Map can also be {@code null} in case of empty model) - * @param contentType the content type selected to render with which should - * match one of the {@link #getSupportedMediaTypes() supported media types}. + * @param model a map with attribute names as keys and corresponding model + * objects as values (the map can also be {@code null} in case of an empty model) + * @param contentType the content type selected to render with, which should + * match one of the {@link #getSupportedMediaTypes() supported media types} * @param exchange the current exchange - * @return {@code Mono} to represent when and if rendering succeeds + * @return a {@code Mono} that represents when and if rendering succeeds */ @Override public Mono render(@Nullable Map model, @Nullable MediaType contentType, @@ -239,9 +241,9 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo * Use the configured {@link ReactiveAdapterRegistry} to adapt asynchronous * attributes to {@code Mono} or {@code Mono>} and then wait to * resolve them into actual values. When the returned {@code Mono} - * completes, the asynchronous attributes in the model would have been + * completes, the asynchronous attributes in the model will have been * replaced with their corresponding resolved values. - * @return result {@code Mono} that completes when the model is ready + * @return result a {@code Mono} that completes when the model is ready * @since 5.1.8 */ protected Mono resolveAsyncAttributes(Map model, ServerWebExchange exchange) { @@ -299,7 +301,7 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo * replaced with their corresponding resolved values. * @return result {@code Mono} that completes when the model is ready * @deprecated as of 5.1.8 this method is still invoked but it is a no-op. - * Please, use {@link #resolveAsyncAttributes(Map, ServerWebExchange)} + * Please use {@link #resolveAsyncAttributes(Map, ServerWebExchange)} * instead. It is invoked after this one and does the actual work. */ @Deprecated @@ -308,14 +310,15 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Create a RequestContext to expose under the specified attribute name. - *

The default implementation creates a standard RequestContext instance - * for the given request and model. Can be overridden in subclasses for - * custom instances. - * @param exchange current exchange - * @param model combined output Map (never {@code null}), - * with dynamic values taking precedence over static attributes - * @return the RequestContext instance + * Create a {@link RequestContext} to expose under the + * {@linkplain #setRequestContextAttribute specified attribute name}. + *

The default implementation creates a standard {@code RequestContext} + * instance for the given exchange and model. + *

Can be overridden in subclasses to create custom instances. + * @param exchange the current exchange + * @param model a combined output Map (never {@code null}), with dynamic values + * taking precedence over static attributes + * @return the {@code RequestContext} instance * @see #setRequestContextAttribute */ protected RequestContext createRequestContext(ServerWebExchange exchange, Map model) { @@ -323,12 +326,12 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo } /** - * Return the {@link RequestDataValueProcessor} to use. + * Get the {@link RequestDataValueProcessor} to use. *

The default implementation looks in the {@link #getApplicationContext() - * Spring configuration} for a {@code RequestDataValueProcessor} bean with + * ApplicationContext} for a {@code RequestDataValueProcessor} bean with * the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}. - * @return the RequestDataValueProcessor, or null if there is none at the - * application context. + * @return the {@code RequestDataValueProcessor}, or {@code null} if there is + * none in the application context */ @Nullable protected RequestDataValueProcessor getRequestDataValueProcessor() { @@ -343,10 +346,10 @@ public abstract class AbstractView implements View, BeanNameAware, ApplicationCo * Subclasses must implement this method to actually render the view. * @param renderAttributes combined output Map (never {@code null}), * with dynamic values taking precedence over static attributes - * @param contentType the content type selected to render with which should - * match one of the {@link #getSupportedMediaTypes() supported media types}. - *@param exchange current exchange @return {@code Mono} to represent when - * and if rendering succeeds + * @param contentType the content type selected to render with, which should + * match one of the {@linkplain #getSupportedMediaTypes() supported media types} + * @param exchange current exchange + * @return a {@code Mono} that represents when and if rendering succeeds */ protected abstract Mono renderInternal(Map renderAttributes, @Nullable MediaType contentType, ServerWebExchange exchange);