Skip to content

Commit 15a3f42

Browse files
committed
Merge branch '6.2.x'
# Conflicts: # spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
2 parents 687c404 + 5c5367a commit 15a3f42

File tree

2 files changed

+50
-44
lines changed

2 files changed

+50
-44
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunction.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public interface RouterFunction<T extends ServerResponse> {
4343
*/
4444
Mono<HandlerFunction<T>> route(ServerRequest request);
4545

46+
47+
// Default methods for composition and filtering
48+
4649
/**
4750
* Return a composed routing function that first invokes this function,
4851
* and then invokes the {@code other} function (of the same response type {@code T})
@@ -99,28 +102,6 @@ default RouterFunction<T> andNest(RequestPredicate predicate, RouterFunction<T>
99102
return and(RouterFunctions.nest(predicate, routerFunction));
100103
}
101104

102-
/**
103-
* Filter all {@linkplain HandlerFunction handler functions} routed by this function with the given
104-
* {@linkplain HandlerFilterFunction filter function}.
105-
* @param <S> the filter return type
106-
* @param filterFunction the filter to apply
107-
* @return the filtered routing function
108-
*/
109-
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) {
110-
return new RouterFunctions.FilteredRouterFunction<>(this, filterFunction);
111-
}
112-
113-
/**
114-
* Accept the given visitor. Default implementation calls
115-
* {@link RouterFunctions.Visitor#unknown(RouterFunction)}; composed {@code RouterFunction}
116-
* implementations are expected to call {@code accept} for all components that make up this
117-
* router function.
118-
* @param visitor the visitor to accept
119-
*/
120-
default void accept(RouterFunctions.Visitor visitor) {
121-
visitor.unknown(this);
122-
}
123-
124105
/**
125106
* Return a new routing function with the given attribute.
126107
* @param name the attribute name
@@ -155,5 +136,27 @@ default RouterFunction<T> withAttributes(Consumer<Map<String, Object>> attribute
155136
return new RouterFunctions.AttributesRouterFunction<>(this, attributes);
156137
}
157138

139+
/**
140+
* Filter all {@linkplain HandlerFunction handler functions} routed by this function
141+
* with the given {@linkplain HandlerFilterFunction filter function}.
142+
* @param <S> the filter return type
143+
* @param filterFunction the filter to apply
144+
* @return the filtered routing function
145+
*/
146+
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) {
147+
return new RouterFunctions.FilteredRouterFunction<>(this, filterFunction);
148+
}
149+
150+
/**
151+
* Accept the given visitor.
152+
* <p>The default implementation calls
153+
* {@link RouterFunctions.Visitor#unknown(RouterFunction)}; composed {@code RouterFunction}
154+
* implementations are expected to call {@code accept} for all components that make up this
155+
* router function.
156+
* @param visitor the visitor to accept
157+
*/
158+
default void accept(RouterFunctions.Visitor visitor) {
159+
visitor.unknown(this);
160+
}
158161

159162
}

spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunction.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public interface RouterFunction<T extends ServerResponse> {
4242
*/
4343
Optional<HandlerFunction<T>> route(ServerRequest request);
4444

45+
46+
// Default methods for composition and filtering
47+
4548
/**
4649
* Return a composed routing function that first invokes this function,
4750
* and then invokes the {@code other} function (of the same response type {@code T})
@@ -98,28 +101,6 @@ default RouterFunction<T> andNest(RequestPredicate predicate, RouterFunction<T>
98101
return and(RouterFunctions.nest(predicate, routerFunction));
99102
}
100103

101-
/**
102-
* Filter all {@linkplain HandlerFunction handler functions} routed by this function with the given
103-
* {@linkplain HandlerFilterFunction filter function}.
104-
* @param <S> the filter return type
105-
* @param filterFunction the filter to apply
106-
* @return the filtered routing function
107-
*/
108-
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) {
109-
return new RouterFunctions.FilteredRouterFunction<>(this, filterFunction);
110-
}
111-
112-
/**
113-
* Accept the given visitor. Default implementation calls
114-
* {@link RouterFunctions.Visitor#unknown(RouterFunction)}; composed {@code RouterFunction}
115-
* implementations are expected to call {@code accept} for all components that make up this
116-
* router function.
117-
* @param visitor the visitor to accept
118-
*/
119-
default void accept(RouterFunctions.Visitor visitor) {
120-
visitor.unknown(this);
121-
}
122-
123104
/**
124105
* Return a new routing function with the given attribute.
125106
* @param name the attribute name
@@ -154,5 +135,27 @@ default RouterFunction<T> withAttributes(Consumer<Map<String, Object>> attribute
154135
return new RouterFunctions.AttributesRouterFunction<>(this, attributes);
155136
}
156137

138+
/**
139+
* Filter all {@linkplain HandlerFunction handler functions} routed by this function
140+
* with the given {@linkplain HandlerFilterFunction filter function}.
141+
* @param <S> the filter return type
142+
* @param filterFunction the filter to apply
143+
* @return the filtered routing function
144+
*/
145+
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) {
146+
return new RouterFunctions.FilteredRouterFunction<>(this, filterFunction);
147+
}
148+
149+
/**
150+
* Accept the given visitor.
151+
* <p>The default implementation calls
152+
* {@link RouterFunctions.Visitor#unknown(RouterFunction)}; composed {@code RouterFunction}
153+
* implementations are expected to call {@code accept} for all components that make up this
154+
* router function.
155+
* @param visitor the visitor to accept
156+
*/
157+
default void accept(RouterFunctions.Visitor visitor) {
158+
visitor.unknown(this);
159+
}
157160

158161
}

0 commit comments

Comments
 (0)