From 61bf6a25b7817014a3bd3ef51532597ebf2860fe Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 12 Sep 2016 15:02:12 +0200 Subject: [PATCH] Renamed 'and' to 'andSame' and 'andOther' to 'and' In RoutingFunction, renamed 'and' to 'andSame', and 'andOther' to 'and' to make the commonly used method name shorter. --- .../web/reactive/function/RoutingFunction.java | 10 +++++----- .../web/reactive/function/RoutingFunctionTests.java | 8 ++++---- .../function/SseHandlerFunctionIntegrationTests.java | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/RoutingFunction.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/RoutingFunction.java index 28c9da9bb2a..c037517edf0 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/RoutingFunction.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/RoutingFunction.java @@ -38,14 +38,14 @@ public interface RoutingFunction { /** * Return a composed routing function that first invokes this function, - * and then invokes the {@code other} function if this route had + * and then invokes the {@code other} function (of the same type {@code T}) if this route had * {@linkplain Optional#empty() no result}. * - * @param other the function to apply when this function has no result + * @param other the function of type {@code T} to apply when this function has no result * @return a composed function that first routes with this function and then the {@code other} function if this * function has no result */ - default RoutingFunction and(RoutingFunction other) { + default RoutingFunction andSame(RoutingFunction other) { return request -> { Optional> result = this.route(request); return result.isPresent() ? result : other.route(request); @@ -54,14 +54,14 @@ public interface RoutingFunction { /** * Return a composed routing function that first invokes this function, - * and then invokes the {@code other} function if this route had + * and then invokes the {@code other} function (of a different type) if this route had * {@linkplain Optional#empty() no result}. * * @param other the function to apply when this function has no result * @return a composed function that first routes with this function and then the {@code other} function if this * function has no result */ - default RoutingFunction andOther(RoutingFunction other) { + default RoutingFunction and(RoutingFunction other) { return request -> { Optional> result = this.route(request). map(CastingUtils::cast); diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/RoutingFunctionTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/RoutingFunctionTests.java index 48317e761fa..abd40f94b7b 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/RoutingFunctionTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/RoutingFunctionTests.java @@ -29,12 +29,12 @@ import static org.junit.Assert.*; public class RoutingFunctionTests { @Test - public void and() throws Exception { + public void andSame() throws Exception { HandlerFunction handlerFunction = request -> Response.ok().build(); RoutingFunction routingFunction1 = request -> Optional.empty(); RoutingFunction routingFunction2 = request -> Optional.of(handlerFunction); - RoutingFunction result = routingFunction1.and(routingFunction2); + RoutingFunction result = routingFunction1.andSame(routingFunction2); assertNotNull(result); MockRequest request = MockRequest.builder().build(); @@ -44,12 +44,12 @@ public class RoutingFunctionTests { } @Test - public void andOther() throws Exception { + public void and() throws Exception { HandlerFunction handlerFunction = request -> Response.ok().body("42"); RoutingFunction routingFunction1 = request -> Optional.empty(); RoutingFunction routingFunction2 = request -> Optional.of(handlerFunction); - RoutingFunction result = routingFunction1.andOther(routingFunction2); + RoutingFunction result = routingFunction1.and(routingFunction2); assertNotNull(result); MockRequest request = MockRequest.builder().build(); diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/SseHandlerFunctionIntegrationTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/SseHandlerFunctionIntegrationTests.java index ed93af6d4fb..0bc85aa39e5 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/SseHandlerFunctionIntegrationTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/function/SseHandlerFunctionIntegrationTests.java @@ -51,8 +51,8 @@ public class SseHandlerFunctionIntegrationTests protected RoutingFunction routingFunction() { SseHandler sseHandler = new SseHandler(); return route(RequestPredicates.GET("/string"), sseHandler::string) - .andOther(route(RequestPredicates.GET("/person"), sseHandler::person)) - .andOther(route(RequestPredicates.GET("/event"), sseHandler::sse)); + .and(route(RequestPredicates.GET("/person"), sseHandler::person)) + .and(route(RequestPredicates.GET("/event"), sseHandler::sse)); }