From 707c7204414fd57240962decb2536d0d42b775d2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Jun 2019 00:05:37 +0200 Subject: [PATCH] Polishing --- .../AbstractMethodMessageHandler.java | 24 +++++++------------ .../support/RouterFunctionMapping.java | 13 +++++----- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java index efbe29872de..43da16b0953 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java @@ -165,8 +165,8 @@ public abstract class AbstractMethodMessageHandler } public String getBeanName() { - return this.beanName != null ? this.beanName : - getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this); + return (this.beanName != null ? this.beanName : + getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this)); } /** @@ -269,7 +269,7 @@ public abstract class AbstractMethodMessageHandler * Detect if the given handler has any methods that can handle messages and if * so register it with the extracted mapping information. *

Note: This method is protected and can be invoked by - * sub-classes, but this should be done on startup only as documented in + * subclasses, but this should be done on startup only as documented in * {@link #registerHandlerMethod}. * @param handler the handler to check, either an instance of a Spring bean name */ @@ -321,7 +321,7 @@ public abstract class AbstractMethodMessageHandler /** * Register a handler method and its unique mapping. *

Note: This method is protected and can be invoked by - * sub-classes. Keep in mind however that the registration is not protected + * subclasses. Keep in mind however that the registration is not protected * for concurrent use, and is expected to be done on startup. * @param handler the bean name of the handler or the handler instance * @param method the method to register @@ -369,7 +369,7 @@ public abstract class AbstractMethodMessageHandler * Return String-based destinations for the given mapping, if any, that can * be used to find matches with a direct lookup (i.e. non-patterns). *

Note: This is completely optional. The mapping - * metadata for a sub-class may support neither direct lookups, nor String + * metadata for a subclass may support neither direct lookups, nor String * based destinations. */ protected abstract Set getDirectLookupMappings(T mapping); @@ -395,7 +395,7 @@ public abstract class AbstractMethodMessageHandler List> matches = new ArrayList<>(); RouteMatcher.Route destination = getDestination(message); - List mappingsByUrl = destination != null ? this.destinationLookup.get(destination.value()) : null; + List mappingsByUrl = (destination != null ? this.destinationLookup.get(destination.value()) : null); if (mappingsByUrl != null) { addMatchesToCollection(mappingsByUrl, message, matches); } @@ -419,10 +419,9 @@ public abstract class AbstractMethodMessageHandler if (comparator.compare(bestMatch, secondBestMatch) == 0) { HandlerMethod m1 = bestMatch.handlerMethod; HandlerMethod m2 = secondBestMatch.handlerMethod; - throw new IllegalStateException( - "Ambiguous handler methods mapped for destination '" + - destination.value() + "': {" + - m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}"); + throw new IllegalStateException("Ambiguous handler methods mapped for destination '" + + (destination != null ? destination.value() : "") + "': {" + + m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}"); } } return bestMatch; @@ -494,13 +493,11 @@ public abstract class AbstractMethodMessageHandler private final HandlerMethod handlerMethod; - Match(T mapping, HandlerMethod handlerMethod) { this.mapping = mapping; this.handlerMethod = handlerMethod; } - public T getMapping() { return this.mapping; } @@ -509,7 +506,6 @@ public abstract class AbstractMethodMessageHandler return this.handlerMethod; } - @Override public String toString() { return this.mapping.toString(); @@ -521,12 +517,10 @@ public abstract class AbstractMethodMessageHandler private final Comparator comparator; - MatchComparator(Comparator comparator) { this.comparator = comparator; } - @Override public int compare(Match match1, Match match2) { return this.comparator.compare(match1.mapping, match2.mapping); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java index 47931503b77..3542b19d9f0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/RouterFunctionMapping.java @@ -40,10 +40,11 @@ import org.springframework.web.servlet.function.ServerRequest; import org.springframework.web.servlet.handler.AbstractHandlerMapping; /** - * {@code HandlerMapping} implementation that supports {@link RouterFunction}s. + * {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}. + * *

If no {@link RouterFunction} is provided at - * {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping will detect - * all router functions in the application context, and consult them in + * {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping + * will detect all router functions in the application context, and consult them in * {@linkplain org.springframework.core.annotation.Order order}. * * @author Arjen Poutsma @@ -62,8 +63,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini /** * Create an empty {@code RouterFunctionMapping}. - *

If this constructor is used, this mapping will detect all {@link RouterFunction} instances - * available in the application context. + *

If this constructor is used, this mapping will detect all + * {@link RouterFunction} instances available in the application context. */ public RouterFunctionMapping() { } @@ -127,7 +128,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini * Detect a all {@linkplain RouterFunction router functions} in the * current application context. */ - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) private void initRouterFunction() { ApplicationContext applicationContext = obtainApplicationContext(); Map beans =