From 5dd48fc068b736536a99fafbb091b9130b1e1cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Wed, 17 Jan 2024 15:08:34 +0100 Subject: [PATCH] Mention PathPattern in functional router Javadoc This commit makes the various supported patterns more discoverable. Closes gh-32045 --- .../function/server/RequestPredicates.java | 9 ++++++++ .../function/server/RouterFunctions.java | 21 +++++++++++++++++++ .../servlet/function/RequestPredicates.java | 9 ++++++++ .../web/servlet/function/RouterFunctions.java | 21 +++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java index 321f07cd9174..b29ba057c189 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java @@ -107,6 +107,7 @@ public static RequestPredicate methods(HttpMethod... httpMethods) { * against the given path pattern. * @param pattern the pattern to match to * @return a predicate that tests against the given path pattern + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate path(String pattern) { Assert.notNull(pattern, "'pattern' must not be null"); @@ -169,6 +170,7 @@ public static RequestPredicate accept(MediaType... mediaTypes) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is GET and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate GET(String pattern) { return method(HttpMethod.GET).and(path(pattern)); @@ -180,6 +182,7 @@ public static RequestPredicate GET(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is HEAD and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate HEAD(String pattern) { return method(HttpMethod.HEAD).and(path(pattern)); @@ -191,6 +194,7 @@ public static RequestPredicate HEAD(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is POST and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate POST(String pattern) { return method(HttpMethod.POST).and(path(pattern)); @@ -202,6 +206,7 @@ public static RequestPredicate POST(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is PUT and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate PUT(String pattern) { return method(HttpMethod.PUT).and(path(pattern)); @@ -213,6 +218,7 @@ public static RequestPredicate PUT(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is PATCH and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate PATCH(String pattern) { return method(HttpMethod.PATCH).and(path(pattern)); @@ -224,6 +230,7 @@ public static RequestPredicate PATCH(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is DELETE and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate DELETE(String pattern) { return method(HttpMethod.DELETE).and(path(pattern)); @@ -235,6 +242,7 @@ public static RequestPredicate DELETE(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is OPTIONS and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate OPTIONS(String pattern) { return method(HttpMethod.OPTIONS).and(path(pattern)); @@ -342,6 +350,7 @@ public interface Visitor { * Receive notification of a path predicate. * @param pattern the path pattern that makes up the predicate * @see RequestPredicates#path(String) + * @see org.springframework.web.util.pattern.PathPattern */ void path(String pattern); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java index c965e4a4b70c..e4e55621593b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java @@ -155,6 +155,7 @@ public static RouterFunction nest( * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return a router function that routes to resources + * @see org.springframework.web.util.pattern.PathPattern * @see #resourceLookupFunction(String, Resource) */ public static RouterFunction resources(String pattern, Resource location) { @@ -173,6 +174,7 @@ public static RouterFunction resources(String pattern, Resource * @param headersConsumer provides access to the HTTP headers for served resources * @return a router function that routes to resources * @since 6.1 + * @see org.springframework.web.util.pattern.PathPattern * @see #resourceLookupFunction(String, Resource) */ public static RouterFunction resources(String pattern, Resource location, @@ -194,6 +196,7 @@ public static RouterFunction resources(String pattern, Resource * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return the default resource lookup function for the given parameters. + * @see org.springframework.web.util.pattern.PathPattern */ public static Function> resourceLookupFunction(String pattern, Resource location) { return new PathResourceLookupFunction(pattern, location); @@ -338,6 +341,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code GET} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder GET(String pattern, HandlerFunction handlerFunction); @@ -369,6 +373,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code GET} requests that * match {@code pattern} and the predicate * @return this builder + * @see org.springframework.web.util.pattern.PathPattern * @see RequestPredicates */ Builder GET(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -388,6 +393,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code HEAD} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder HEAD(String pattern, HandlerFunction handlerFunction); @@ -411,6 +417,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code HEAD} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -429,6 +436,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code POST} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder POST(String pattern, HandlerFunction handlerFunction); @@ -460,6 +468,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code POST} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder POST(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -478,6 +487,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PUT} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PUT(String pattern, HandlerFunction handlerFunction); @@ -509,6 +519,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PUT} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -527,6 +538,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PATCH} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PATCH(String pattern, HandlerFunction handlerFunction); @@ -558,6 +570,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PATCH} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -576,6 +589,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code DELETE} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder DELETE(String pattern, HandlerFunction handlerFunction); @@ -599,6 +613,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code DELETE} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -617,6 +632,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code OPTIONS} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder OPTIONS(String pattern, HandlerFunction handlerFunction); @@ -640,6 +656,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code OPTIONS} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -685,6 +702,7 @@ public interface Builder { * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder resources(String pattern, Resource location); @@ -700,6 +718,7 @@ public interface Builder { * @param headersConsumer provides access to the HTTP headers for served resources * @return this builder * @since 6.1 + * @see org.springframework.web.util.pattern.PathPattern */ Builder resources(String pattern, Resource location, BiConsumer headersConsumer); @@ -790,6 +809,7 @@ public interface Builder { * @param routerFunctionSupplier supplier for the nested router function to delegate to if * the pattern matches * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder path(String pattern, Supplier> routerFunctionSupplier); @@ -812,6 +832,7 @@ public interface Builder { * @param builderConsumer consumer for a {@code Builder} that provides the nested router * function * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder path(String pattern, Consumer builderConsumer); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java index 8cca6f7d8a26..22007b6e8567 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java @@ -107,6 +107,7 @@ public static RequestPredicate methods(HttpMethod... httpMethods) { * against the given path pattern. * @param pattern the pattern to match to * @return a predicate that tests against the given path pattern + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate path(String pattern) { Assert.notNull(pattern, "'pattern' must not be null"); @@ -169,6 +170,7 @@ public static RequestPredicate accept(MediaType... mediaTypes) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is GET and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate GET(String pattern) { return method(HttpMethod.GET).and(path(pattern)); @@ -180,6 +182,7 @@ public static RequestPredicate GET(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is HEAD and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate HEAD(String pattern) { return method(HttpMethod.HEAD).and(path(pattern)); @@ -191,6 +194,7 @@ public static RequestPredicate HEAD(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is POST and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate POST(String pattern) { return method(HttpMethod.POST).and(path(pattern)); @@ -202,6 +206,7 @@ public static RequestPredicate POST(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is PUT and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate PUT(String pattern) { return method(HttpMethod.PUT).and(path(pattern)); @@ -213,6 +218,7 @@ public static RequestPredicate PUT(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is PATCH and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate PATCH(String pattern) { return method(HttpMethod.PATCH).and(path(pattern)); @@ -224,6 +230,7 @@ public static RequestPredicate PATCH(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is DELETE and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate DELETE(String pattern) { return method(HttpMethod.DELETE).and(path(pattern)); @@ -235,6 +242,7 @@ public static RequestPredicate DELETE(String pattern) { * @param pattern the path pattern to match against * @return a predicate that matches if the request method is OPTIONS and if the given pattern * matches against the request path + * @see org.springframework.web.util.pattern.PathPattern */ public static RequestPredicate OPTIONS(String pattern) { return method(HttpMethod.OPTIONS).and(path(pattern)); @@ -341,6 +349,7 @@ public interface Visitor { * Receive notification of a path predicate. * @param pattern the path pattern that makes up the predicate * @see RequestPredicates#path(String) + * @see org.springframework.web.util.pattern.PathPattern */ void path(String pattern); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java index 027bbf6b4ba1..6693950b23cb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java @@ -138,6 +138,7 @@ public static RouterFunction nest( * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return a router function that routes to resources + * @see org.springframework.web.util.pattern.PathPattern * @see #resourceLookupFunction(String, Resource) */ public static RouterFunction resources(String pattern, Resource location) { @@ -156,6 +157,7 @@ public static RouterFunction resources(String pattern, Resource * @param headersConsumer provides access to the HTTP headers for served resources * @return a router function that routes to resources * @since 6.1 + * @see org.springframework.web.util.pattern.PathPattern * @see #resourceLookupFunction(String, Resource) */ public static RouterFunction resources(String pattern, Resource location, @@ -177,6 +179,7 @@ public static RouterFunction resources(String pattern, Resource * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return the default resource lookup function for the given parameters. + * @see org.springframework.web.util.pattern.PathPattern */ public static Function> resourceLookupFunction(String pattern, Resource location) { return new PathResourceLookupFunction(pattern, location); @@ -249,6 +252,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code GET} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder GET(String pattern, HandlerFunction handlerFunction); @@ -280,6 +284,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code GET} requests that * match {@code pattern} and the predicate * @return this builder + * @see org.springframework.web.util.pattern.PathPattern * @see RequestPredicates */ Builder GET(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -299,6 +304,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code HEAD} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder HEAD(String pattern, HandlerFunction handlerFunction); @@ -322,6 +328,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code HEAD} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -340,6 +347,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code POST} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder POST(String pattern, HandlerFunction handlerFunction); @@ -371,6 +379,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code POST} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder POST(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -389,6 +398,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PUT} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PUT(String pattern, HandlerFunction handlerFunction); @@ -420,6 +430,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PUT} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -438,6 +449,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PATCH} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PATCH(String pattern, HandlerFunction handlerFunction); @@ -469,6 +481,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code PATCH} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -487,6 +500,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code DELETE} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder DELETE(String pattern, HandlerFunction handlerFunction); @@ -510,6 +524,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code DELETE} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -528,6 +543,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code OPTIONS} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder OPTIONS(String pattern, HandlerFunction handlerFunction); @@ -551,6 +567,7 @@ public interface Builder { * @param handlerFunction the handler function to handle all {@code OPTIONS} requests that * match {@code pattern} * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction handlerFunction); @@ -595,6 +612,7 @@ public interface Builder { * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder resources(String pattern, Resource location); @@ -610,6 +628,7 @@ public interface Builder { * @param headersConsumer provides access to the HTTP headers for served resources * @return this builder * @since 6.1 + * @see org.springframework.web.util.pattern.PathPattern */ Builder resources(String pattern, Resource location, BiConsumer headersConsumer); @@ -700,6 +719,7 @@ public interface Builder { * @param routerFunctionSupplier supplier for the nested router function to delegate to if * the pattern matches * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder path(String pattern, Supplier> routerFunctionSupplier); @@ -722,6 +742,7 @@ public interface Builder { * @param builderConsumer consumer for a {@code Builder} that provides the nested router * function * @return this builder + * @see org.springframework.web.util.pattern.PathPattern */ Builder path(String pattern, Consumer builderConsumer);