Polishing

This commit is contained in:
Sam Brannen
2024-02-16 13:37:39 +01:00
parent 6791ea94a0
commit 7c07c43201
16 changed files with 120 additions and 124 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -47,15 +47,15 @@ import org.springframework.javapoet.CodeBlock;
abstract class BeanDefinitionPropertyValueCodeGeneratorDelegates {
/**
* Return the {@link Delegate} implementations for common bean definition
* property value types. These are:
* A list of {@link Delegate} implementations for the following common bean
* definition property value types.
* <ul>
* <li>{@link ManagedList},</li>
* <li>{@link ManagedSet},</li>
* <li>{@link ManagedMap},</li>
* <li>{@link LinkedHashMap},</li>
* <li>{@link BeanReference},</li>
* <li>{@link TypedStringValue}.</li>
* <li>{@link ManagedList}</li>
* <li>{@link ManagedSet}</li>
* <li>{@link ManagedMap}</li>
* <li>{@link LinkedHashMap}</li>
* <li>{@link BeanReference}</li>
* <li>{@link TypedStringValue}</li>
* </ul>
* When combined with {@linkplain ValueCodeGeneratorDelegates#INSTANCES the
* delegates for common value types}, this should be added first as they have

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -20,7 +20,6 @@ import java.lang.reflect.AnnotatedElement;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Stream;
import org.springframework.javapoet.AnnotationSpec;
@@ -118,9 +117,7 @@ class CodeWarnings {
@Override
public String toString() {
return new StringJoiner(", ", CodeWarnings.class.getSimpleName(), "")
.add(this.warnings.toString())
.toString();
return CodeWarnings.class.getSimpleName() + this.warnings;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -43,14 +43,10 @@ class CodeWarningsTests {
private static final TestCompiler TEST_COMPILER = TestCompiler.forSystem()
.withCompilerOptions("-Xlint:all", "-Werror");
private final CodeWarnings codeWarnings;
private final CodeWarnings codeWarnings = new CodeWarnings();
private final TestGenerationContext generationContext;
private final TestGenerationContext generationContext = new TestGenerationContext();
CodeWarningsTests() {
this.codeWarnings = new CodeWarnings();
this.generationContext = new TestGenerationContext();
}
@Test
void registerNoWarningDoesNotIncludeAnnotation() {
@@ -67,8 +63,7 @@ class CodeWarningsTests {
compile(method -> {
this.codeWarnings.suppress(method);
method.addStatement("$T bean = new $T()", DeprecatedBean.class, DeprecatedBean.class);
}, compiled -> assertThat(compiled.getSourceFile())
.contains("@SuppressWarnings(\"deprecation\")"));
}, compiled -> assertThat(compiled.getSourceFile()).contains("@SuppressWarnings(\"deprecation\")"));
}
@Test
@@ -80,26 +75,25 @@ class CodeWarningsTests {
this.codeWarnings.suppress(method);
method.addStatement("$T bean = new $T()", DeprecatedBean.class, DeprecatedBean.class);
method.addStatement("$T another = new $T()", DeprecatedForRemovalBean.class, DeprecatedForRemovalBean.class);
}, compiled -> assertThat(compiled.getSourceFile())
.contains("@SuppressWarnings({ \"deprecation\", \"removal\" })"));
}, compiled -> assertThat(compiled.getSourceFile()).contains("@SuppressWarnings({ \"deprecation\", \"removal\" })"));
}
@Test
@SuppressWarnings("deprecation")
void detectDeprecationOnAnnotatedElementWithDeprecated() {
this.codeWarnings.detectDeprecation(DeprecatedBean.class);
assertThat(this.codeWarnings.getWarnings()).containsExactly("deprecation");
assertThat(this.codeWarnings.getWarnings()).containsOnly("deprecation");
}
@Test
@SuppressWarnings("removal")
void detectDeprecationOnAnnotatedElementWithDeprecatedForRemoval() {
this.codeWarnings.detectDeprecation(DeprecatedForRemovalBean.class);
assertThat(this.codeWarnings.getWarnings()).containsExactly("removal");
assertThat(this.codeWarnings.getWarnings()).containsOnly("removal");
}
@Test
void toStringIncludeWarnings() {
void toStringIncludesWarnings() {
this.codeWarnings.register("deprecation");
this.codeWarnings.register("rawtypes");
assertThat(this.codeWarnings).hasToString("CodeWarnings[deprecation, rawtypes]");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.

View File

@@ -142,11 +142,11 @@ public final class CronExpression {
*
* <p>Example expressions:
* <ul>
* <li>{@code "0 0 * * * *"} = the top of every hour of every day.</li>
* <li><code>"*&#47;10 * * * * *"</code> = every ten seconds.</li>
* <li>{@code "0 0 8-10 * * *"} = 8, 9 and 10 o'clock of every day.</li>
* <li>{@code "0 0 6,19 * * *"} = 6:00 AM and 7:00 PM every day.</li>
* <li>{@code "0 0/30 8-10 * * *"} = 8:00, 8:30, 9:00, 9:30, 10:00 and 10:30 every day.</li>
* <li>{@code "0 0 * * * *"} = the top of every hour of every day</li>
* <li><code>"*&#47;10 * * * * *"</code> = every ten seconds</li>
* <li>{@code "0 0 8-10 * * *"} = 8, 9 and 10 o'clock of every day</li>
* <li>{@code "0 0 6,19 * * *"} = 6:00 AM and 7:00 PM every day</li>
* <li>{@code "0 0/30 8-10 * * *"} = 8:00, 8:30, 9:00, 9:30, 10:00 and 10:30 every day</li>
* <li>{@code "0 0 9-17 * * MON-FRI"} = on the hour nine-to-five weekdays</li>
* <li>{@code "0 0 0 25 12 ?"} = every Christmas Day at midnight</li>
* <li>{@code "0 0 0 L * *"} = last day of the month at midnight</li>
@@ -159,13 +159,13 @@ public final class CronExpression {
* <li>{@code "0 0 0 ? * MON#1"} = the first Monday in the month at midnight</li>
* </ul>
*
* <p>The following macros are also supported:
* <p>The following macros are also supported.
* <ul>
* <li>{@code "@yearly"} (or {@code "@annually"}) to run un once a year, i.e. {@code "0 0 0 1 1 *"},</li>
* <li>{@code "@monthly"} to run once a month, i.e. {@code "0 0 0 1 * *"},</li>
* <li>{@code "@weekly"} to run once a week, i.e. {@code "0 0 0 * * 0"},</li>
* <li>{@code "@daily"} (or {@code "@midnight"}) to run once a day, i.e. {@code "0 0 0 * * *"},</li>
* <li>{@code "@hourly"} to run once an hour, i.e. {@code "0 0 * * * *"}.</li>
* <li>{@code "@yearly"} (or {@code "@annually"}) to run un once a year, i.e. {@code "0 0 0 1 1 *"}</li>
* <li>{@code "@monthly"} to run once a month, i.e. {@code "0 0 0 1 * *"}</li>
* <li>{@code "@weekly"} to run once a week, i.e. {@code "0 0 0 * * 0"}</li>
* <li>{@code "@daily"} (or {@code "@midnight"}) to run once a day, i.e. {@code "0 0 0 * * *"}</li>
* <li>{@code "@hourly"} to run once an hour, i.e. {@code "0 0 * * * *"}</li>
* </ul>
* @param expression the expression string to parse
* @return the parsed {@code CronExpression} object

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -47,19 +47,19 @@ import org.springframework.util.ObjectUtils;
public abstract class ValueCodeGeneratorDelegates {
/**
* Return the {@link Delegate} implementations for common value types.
* These are:
* A list of {@link Delegate} implementations for the following common value
* types.
* <ul>
* <li>Primitive types,</li>
* <li>String,</li>
* <li>Charset,</li>
* <li>Enum,</li>
* <li>Class,</li>
* <li>{@link ResolvableType},</li>
* <li>Array,</li>
* <li>List via {@code List.of},</li>
* <li>Set via {@code Set.of} and support of {@link LinkedHashSet},</li>
* <li>Map via {@code Map.of} or {@code Map.ofEntries}.</li>
* <li>Primitive types</li>
* <li>String</li>
* <li>Charset</li>
* <li>Enum</li>
* <li>Class</li>
* <li>{@link ResolvableType}</li>
* <li>Array</li>
* <li>List via {@code List.of}</li>
* <li>Set via {@code Set.of} and support for {@link LinkedHashSet}</li>
* <li>Map via {@code Map.of} or {@code Map.ofEntries}</li>
* </ul>
* Those implementations do not require the {@link ValueCodeGenerator} to be
* {@linkplain ValueCodeGenerator#scoped(GeneratedMethods) scoped}.

View File

@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -123,9 +122,7 @@ public final class TypeHint implements ConditionalHint {
@Override
public String toString() {
return new StringJoiner(", ", TypeHint.class.getSimpleName() + "[", "]")
.add("type=" + this.type)
.toString();
return TypeHint.class.getSimpleName() + "[type=" + this.type + "]";
}
/**

View File

@@ -1169,7 +1169,8 @@ public class ResolvableType implements Serializable {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(generics, "Generics array must not be null");
TypeVariable<?>[] variables = clazz.getTypeParameters();
Assert.isTrue(variables.length == generics.length, () -> "Mismatched number of generics specified for " + clazz.toGenericString());
Assert.isTrue(variables.length == generics.length,
() -> "Mismatched number of generics specified for " + clazz.toGenericString());
Type[] arguments = new Type[generics.length];
for (int i = 0; i < generics.length; i++) {

View File

@@ -1019,10 +1019,10 @@ public abstract class ClassUtils {
}
Class<?> clazz = value.getClass();
if (Proxy.isProxyClass(clazz)) {
String prefix = clazz.getName() + " implementing ";
String prefix = clazz.getTypeName() + " implementing ";
StringJoiner result = new StringJoiner(",", prefix, "");
for (Class<?> ifc : clazz.getInterfaces()) {
result.add(ifc.getName());
result.add(ifc.getTypeName());
}
return result.toString();
}

View File

@@ -46,13 +46,13 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
* a given key can involve the resolution of nested placeholders. Default values
* can also have placeholders.
*
* <p>For situations where the syntax of a valid placeholder match a String that
* <p>For situations where the syntax of a valid placeholder matches a String that
* must be rendered as is, the placeholder can be escaped using an {@code escape}
* character. For instance {@code \${name}} resolves as {@code ${name}}.
*
* <p>The prefix, suffix, separator, and escape characters are configurable. Only
* the prefix and suffix are mandatory and the support of default values or
* escaping are conditional on providing a non-null value for them.
* the prefix and suffix are mandatory, and the support for default values or
* escaping is conditional on providing non-null values for them.
*
* <p>This parser makes sure to resolves placeholders as lazily as possible.
*
@@ -64,7 +64,11 @@ final class PlaceholderParser {
private static final Log logger = LogFactory.getLog(PlaceholderParser.class);
private static final Map<String, String> wellKnownSimplePrefixes = Map.of(
"}", "{", "]", "[", ")", "(");
"}", "{",
"]", "[",
")", "("
);
private final String prefix;
@@ -80,9 +84,9 @@ final class PlaceholderParser {
@Nullable
private final Character escape;
/**
* Create an instance using the specified input for the parser.
*
* @param prefix the prefix that denotes the start of a placeholder
* @param suffix the suffix that denotes the end of a placeholder
* @param ignoreUnresolvablePlaceholders whether unresolvable placeholders
@@ -90,7 +94,7 @@ final class PlaceholderParser {
* @param separator the separating character between the placeholder
* variable and the associated default value, if any
* @param escape the character to use at the beginning of a placeholder
* to escape it and render it as is
* prefix or separator to escape it and render it as is
*/
PlaceholderParser(String prefix, String suffix, boolean ignoreUnresolvablePlaceholders,
@Nullable String separator, @Nullable Character escape) {
@@ -109,7 +113,7 @@ final class PlaceholderParser {
}
/**
* Replaces all placeholders of format {@code ${name}} with the value returned
* Replace all placeholders of format {@code ${name}} with the value returned
* from the supplied {@link PlaceholderResolver}.
* @param value the value containing the placeholders to be replaced
* @param placeholderResolver the {@code PlaceholderResolver} to use for replacement
@@ -138,8 +142,7 @@ final class PlaceholderParser {
LinkedList<Part> parts = new LinkedList<>();
int startIndex = nextStartPrefix(value, 0);
if (startIndex == -1) {
Part part = inPlaceholder ? createSimplePlaceholderPart(value)
: new TextPart(value);
Part part = (inPlaceholder ? createSimplePlaceholderPart(value) : new TextPart(value));
parts.add(part);
return parts;
}
@@ -168,13 +171,13 @@ final class PlaceholderParser {
}
// Add rest of text if necessary
addText(value, position, value.length(), parts);
return inPlaceholder ? List.of(createNestedPlaceholderPart(value, parts)) : parts;
return (inPlaceholder ? List.of(createNestedPlaceholderPart(value, parts)) : parts);
}
private SimplePlaceholderPart createSimplePlaceholderPart(String text) {
String[] keyAndDefault = splitKeyAndDefault(text);
return (keyAndDefault != null) ? new SimplePlaceholderPart(text, keyAndDefault[0], keyAndDefault[1])
: new SimplePlaceholderPart(text, text, null);
return ((keyAndDefault != null) ? new SimplePlaceholderPart(text, keyAndDefault[0], keyAndDefault[1]) :
new SimplePlaceholderPart(text, text, null));
}
private NestedPlaceholderPart createNestedPlaceholderPart(String text, List<Part> parts) {
@@ -291,7 +294,7 @@ final class PlaceholderParser {
}
/**
* Provide the necessary to handle and resolve underlying placeholders.
* Provide the necessary context to handle and resolve underlying placeholders.
*/
static class PartResolutionContext implements PlaceholderResolver {
@@ -308,6 +311,7 @@ final class PlaceholderParser {
@Nullable
private Set<String> visitedPlaceholders;
PartResolutionContext(PlaceholderResolver resolver, String prefix, String suffix,
boolean ignoreUnresolvablePlaceholders, Function<String, List<Part>> parser) {
this.prefix = prefix;

View File

@@ -22,7 +22,8 @@ import org.springframework.lang.Nullable;
/**
* Utility class for working with Strings that have placeholder values in them.
* A placeholder takes the form {@code ${name}}. Using {@code PropertyPlaceholderHelper}
*
* <p>A placeholder takes the form {@code ${name}}. Using {@code PropertyPlaceholderHelper}
* these placeholders can be substituted for user-supplied values.
*
* <p>Values for substitution can be supplied using a {@link Properties} instance or
@@ -39,7 +40,7 @@ public class PropertyPlaceholderHelper {
/**
* Creates a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
* Create a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
* Unresolvable placeholders are ignored.
* @param placeholderPrefix the prefix that denotes the start of a placeholder
* @param placeholderSuffix the suffix that denotes the end of a placeholder
@@ -49,14 +50,15 @@ public class PropertyPlaceholderHelper {
}
/**
* Creates a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
* Create a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
* @param placeholderPrefix the prefix that denotes the start of a placeholder
* @param placeholderSuffix the suffix that denotes the end of a placeholder
* @param valueSeparator the separating character between the placeholder variable
* and the associated default value, if any
* @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should
* be ignored ({@code true}) or cause an exception ({@code false})
* @deprecated in favor of {@link PropertyPlaceholderHelper#PropertyPlaceholderHelper(String, String, String, boolean, Character)}
* @deprecated as of 6.2, in favor of
* {@link PropertyPlaceholderHelper#PropertyPlaceholderHelper(String, String, String, Character, boolean)}
*/
@Deprecated(since = "6.2", forRemoval = true)
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
@@ -66,7 +68,7 @@ public class PropertyPlaceholderHelper {
}
/**
* Creates a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
* Create a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
* @param placeholderPrefix the prefix that denotes the start of a placeholder
* @param placeholderSuffix the suffix that denotes the end of a placeholder
* @param valueSeparator the separating character between the placeholder variable
@@ -89,7 +91,7 @@ public class PropertyPlaceholderHelper {
/**
* Replaces all placeholders of format {@code ${name}} with the corresponding
* Replace all placeholders of format {@code ${name}} with the corresponding
* property from the supplied {@link Properties}.
* @param value the value containing the placeholders to be replaced
* @param properties the {@code Properties} to use for replacement
@@ -101,7 +103,7 @@ public class PropertyPlaceholderHelper {
}
/**
* Replaces all placeholders of format {@code ${name}} with the value returned
* Replace all placeholders of format {@code ${name}} with the value returned
* from the supplied {@link PlaceholderResolver}.
* @param value the value containing the placeholders to be replaced
* @param placeholderResolver the {@code PlaceholderResolver} to use for replacement

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.

View File

@@ -336,7 +336,7 @@ class PlaceholderParserTests {
if (pairs.length % 2 == 1) {
throw new IllegalArgumentException("size must be even, it is a set of key=value pairs");
}
PlaceholderResolver resolver = mock(PlaceholderResolver.class);
PlaceholderResolver resolver = mock();
for (int i = 0; i < pairs.length; i += 2) {
String key = pairs[i];
String value = pairs[i + 1];

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -43,11 +43,9 @@ public interface ClientHttpRequestInterceptor {
* wrap} the request to filter HTTP attributes.</li>
* <li>Optionally modify the body of the request.</li>
* <ul>
* <li><strong>Either</strong>
* <li>execute the request using
* {@link ClientHttpRequestExecution#execute(org.springframework.http.HttpRequest, byte[])},</li>
* <li><strong>or</strong></li>
* <li>do not execute the request to block the execution altogether.</li>
* <li><strong>either</strong> execute the request using
* {@link ClientHttpRequestExecution#execute(HttpRequest, byte[])}</li>
* <li><strong>or</strong> do not execute the request to block the execution altogether</li>
* </ul>
* <li>Optionally wrap the response to filter HTTP attributes.</li>
* </ol>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -155,16 +155,17 @@ public interface RestClient {
}
/**
* Create a new {@code RestClient} based on the configuration of the
* given {@code RestTemplate}. The returned builder is configured with the
* template's
* Create a new {@code RestClient} based on the configuration of the given
* {@code RestTemplate}.
* <p>The returned builder is configured with the following attributes of
* the template.
* <ul>
* <li>{@link RestTemplate#getRequestFactory() ClientHttpRequestFactory},</li>
* <li>{@link RestTemplate#getMessageConverters() HttpMessageConverters},</li>
* <li>{@link RestTemplate#getInterceptors() ClientHttpRequestInterceptors},</li>
* <li>{@link RestTemplate#getClientHttpRequestInitializers() ClientHttpRequestInitializers},</li>
* <li>{@link RestTemplate#getUriTemplateHandler() UriBuilderFactory}, and</li>
* <li>{@linkplain RestTemplate#getErrorHandler() error handler}.</li>
* <li>{@link RestTemplate#getRequestFactory() ClientHttpRequestFactory}</li>
* <li>{@link RestTemplate#getMessageConverters() HttpMessageConverters}</li>
* <li>{@link RestTemplate#getInterceptors() ClientHttpRequestInterceptors}</li>
* <li>{@link RestTemplate#getClientHttpRequestInitializers() ClientHttpRequestInitializers}</li>
* <li>{@link RestTemplate#getUriTemplateHandler() UriBuilderFactory}</li>
* <li>{@linkplain RestTemplate#getErrorHandler() error handler}</li>
* </ul>
* @param restTemplate the rest template to base the returned client's
* configuration on
@@ -184,15 +185,16 @@ public interface RestClient {
/**
* Obtain a {@code RestClient} builder based on the configuration of the
* given {@code RestTemplate}. The returned builder is configured with the
* template's
* given {@code RestTemplate}.
* <p>The returned builder is configured with the following attributes of
* the template.
* <ul>
* <li>{@link RestTemplate#getRequestFactory() ClientHttpRequestFactory},</li>
* <li>{@link RestTemplate#getMessageConverters() HttpMessageConverters},</li>
* <li>{@link RestTemplate#getInterceptors() ClientHttpRequestInterceptors},</li>
* <li>{@link RestTemplate#getClientHttpRequestInitializers() ClientHttpRequestInitializers},</li>
* <li>{@link RestTemplate#getUriTemplateHandler() UriBuilderFactory}, and</li>
* <li>{@linkplain RestTemplate#getErrorHandler() error handler}.</li>
* <li>{@link RestTemplate#getRequestFactory() ClientHttpRequestFactory}</li>
* <li>{@link RestTemplate#getMessageConverters() HttpMessageConverters}</li>
* <li>{@link RestTemplate#getInterceptors() ClientHttpRequestInterceptors}</li>
* <li>{@link RestTemplate#getClientHttpRequestInitializers() ClientHttpRequestInitializers}</li>
* <li>{@link RestTemplate#getUriTemplateHandler() UriBuilderFactory}</li>
* <li>{@linkplain RestTemplate#getErrorHandler() error handler}</li>
* </ul>
* @param restTemplate the rest template to base the returned builder's
* configuration on

View File

@@ -79,8 +79,8 @@ public abstract class RouterFunctions {
RouterFunctions.class.getName() + ".uriTemplateVariables";
/**
* Name of the {@link ServerWebExchange#getAttributes() attribute} that
* contains the matching pattern, as a {@link org.springframework.web.util.pattern.PathPattern}.
* Name of the {@link ServerWebExchange#getAttributes() attribute} that contains
* the matching pattern, as an {@link org.springframework.web.util.pattern.PathPattern}.
*/
public static final String MATCHING_PATTERN_ATTRIBUTE =
RouterFunctions.class.getName() + ".matchingPattern";
@@ -263,42 +263,43 @@ public abstract class RouterFunctions {
}
/**
* Convert the given {@linkplain RouterFunction router function} into a {@link HttpHandler}.
* This conversion uses {@linkplain HandlerStrategies#builder() default strategies}.
* <p>The returned handler can be adapted to run in
* Convert the given {@linkplain RouterFunction router function} into an
* {@link HttpHandler}, using the {@linkplain HandlerStrategies#builder()
* default strategies}.
* <p>The returned handler can be adapted to run in the following environments.
* <ul>
* <li>Servlet environments using the
* {@link org.springframework.http.server.reactive.ServletHttpHandlerAdapter},</li>
* {@link org.springframework.http.server.reactive.ServletHttpHandlerAdapter}</li>
* <li>Reactor using the
* {@link org.springframework.http.server.reactive.ReactorHttpHandlerAdapter},</li>
* {@link org.springframework.http.server.reactive.ReactorHttpHandlerAdapter}
* <li>Undertow using the
* {@link org.springframework.http.server.reactive.UndertowHttpHandlerAdapter}.</li>
* {@link org.springframework.http.server.reactive.UndertowHttpHandlerAdapter}</li>
* </ul>
* <p>Note that {@code HttpWebHandlerAdapter} also implements {@link WebHandler}, allowing
* for additional filter and exception handler registration through
* <p>Note that {@code HttpWebHandlerAdapter} also implements {@link WebHandler},
* allowing for additional filter and exception handler registration through
* {@link WebHttpHandlerBuilder}.
* @param routerFunction the router function to convert
* @return an HTTP handler that handles HTTP request using the given router function
* @return an HTTP handler that handles HTTP requests using the given router function
*/
public static HttpHandler toHttpHandler(RouterFunction<?> routerFunction) {
return toHttpHandler(routerFunction, HandlerStrategies.withDefaults());
}
/**
* Convert the given {@linkplain RouterFunction router function} into a {@link HttpHandler},
* using the given strategies.
* <p>The returned {@code HttpHandler} can be adapted to run in
* Convert the given {@linkplain RouterFunction router function} into an
* {@link HttpHandler}, using the given strategies.
* <p>The returned handler can be adapted to run in the following environments.
* <ul>
* <li>Servlet environments using the
* {@link org.springframework.http.server.reactive.ServletHttpHandlerAdapter},</li>
* {@link org.springframework.http.server.reactive.ServletHttpHandlerAdapter}</li>
* <li>Reactor using the
* {@link org.springframework.http.server.reactive.ReactorHttpHandlerAdapter},</li>
* {@link org.springframework.http.server.reactive.ReactorHttpHandlerAdapter}</li>
* <li>Undertow using the
* {@link org.springframework.http.server.reactive.UndertowHttpHandlerAdapter}.</li>
* {@link org.springframework.http.server.reactive.UndertowHttpHandlerAdapter}</li>
* </ul>
* @param routerFunction the router function to convert
* @param strategies the strategies to use
* @return an HTTP handler that handles HTTP request using the given router function
* @return an HTTP handler that handles HTTP requests using the given router function
*/
public static HttpHandler toHttpHandler(RouterFunction<?> routerFunction, HandlerStrategies strategies) {
WebHandler webHandler = toWebHandler(routerFunction, strategies);