Skip to content

Commit 707c720

Browse files
committed
Polishing
1 parent 7e02358 commit 707c720

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public void setBeanName(String name) {
165165
}
166166

167167
public String getBeanName() {
168-
return this.beanName != null ? this.beanName :
169-
getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this);
168+
return (this.beanName != null ? this.beanName :
169+
getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this));
170170
}
171171

172172
/**
@@ -269,7 +269,7 @@ private void initHandlerMethods() {
269269
* Detect if the given handler has any methods that can handle messages and if
270270
* so register it with the extracted mapping information.
271271
* <p><strong>Note:</strong> This method is protected and can be invoked by
272-
* sub-classes, but this should be done on startup only as documented in
272+
* subclasses, but this should be done on startup only as documented in
273273
* {@link #registerHandlerMethod}.
274274
* @param handler the handler to check, either an instance of a Spring bean name
275275
*/
@@ -321,7 +321,7 @@ private String formatMappings(Class<?> userType, Map<Method, T> methods) {
321321
/**
322322
* Register a handler method and its unique mapping.
323323
* <p><strong>Note:</strong> This method is protected and can be invoked by
324-
* sub-classes. Keep in mind however that the registration is not protected
324+
* subclasses. Keep in mind however that the registration is not protected
325325
* for concurrent use, and is expected to be done on startup.
326326
* @param handler the bean name of the handler or the handler instance
327327
* @param method the method to register
@@ -369,7 +369,7 @@ private HandlerMethod createHandlerMethod(Object handler, Method method) {
369369
* Return String-based destinations for the given mapping, if any, that can
370370
* be used to find matches with a direct lookup (i.e. non-patterns).
371371
* <p><strong>Note:</strong> This is completely optional. The mapping
372-
* metadata for a sub-class may support neither direct lookups, nor String
372+
* metadata for a subclass may support neither direct lookups, nor String
373373
* based destinations.
374374
*/
375375
protected abstract Set<String> getDirectLookupMappings(T mapping);
@@ -395,7 +395,7 @@ private Match<T> getHandlerMethod(Message<?> message) {
395395
List<Match<T>> matches = new ArrayList<>();
396396

397397
RouteMatcher.Route destination = getDestination(message);
398-
List<T> mappingsByUrl = destination != null ? this.destinationLookup.get(destination.value()) : null;
398+
List<T> mappingsByUrl = (destination != null ? this.destinationLookup.get(destination.value()) : null);
399399
if (mappingsByUrl != null) {
400400
addMatchesToCollection(mappingsByUrl, message, matches);
401401
}
@@ -419,10 +419,9 @@ private Match<T> getHandlerMethod(Message<?> message) {
419419
if (comparator.compare(bestMatch, secondBestMatch) == 0) {
420420
HandlerMethod m1 = bestMatch.handlerMethod;
421421
HandlerMethod m2 = secondBestMatch.handlerMethod;
422-
throw new IllegalStateException(
423-
"Ambiguous handler methods mapped for destination '" +
424-
destination.value() + "': {" +
425-
m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}");
422+
throw new IllegalStateException("Ambiguous handler methods mapped for destination '" +
423+
(destination != null ? destination.value() : "") + "': {" +
424+
m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}");
426425
}
427426
}
428427
return bestMatch;
@@ -494,13 +493,11 @@ private static class Match<T> {
494493

495494
private final HandlerMethod handlerMethod;
496495

497-
498496
Match(T mapping, HandlerMethod handlerMethod) {
499497
this.mapping = mapping;
500498
this.handlerMethod = handlerMethod;
501499
}
502500

503-
504501
public T getMapping() {
505502
return this.mapping;
506503
}
@@ -509,7 +506,6 @@ public HandlerMethod getHandlerMethod() {
509506
return this.handlerMethod;
510507
}
511508

512-
513509
@Override
514510
public String toString() {
515511
return this.mapping.toString();
@@ -521,12 +517,10 @@ private class MatchComparator implements Comparator<Match<T>> {
521517

522518
private final Comparator<T> comparator;
523519

524-
525520
MatchComparator(Comparator<T> comparator) {
526521
this.comparator = comparator;
527522
}
528523

529-
530524
@Override
531525
public int compare(Match<T> match1, Match<T> match2) {
532526
return this.comparator.compare(match1.mapping, match2.mapping);

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@
4040
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
4141

4242
/**
43-
* {@code HandlerMapping} implementation that supports {@link RouterFunction}s.
43+
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
44+
*
4445
* <p>If no {@link RouterFunction} is provided at
45-
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping will detect
46-
* all router functions in the application context, and consult them in
46+
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping
47+
* will detect all router functions in the application context, and consult them in
4748
* {@linkplain org.springframework.core.annotation.Order order}.
4849
*
4950
* @author Arjen Poutsma
@@ -62,8 +63,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
6263

6364
/**
6465
* Create an empty {@code RouterFunctionMapping}.
65-
* <p>If this constructor is used, this mapping will detect all {@link RouterFunction} instances
66-
* available in the application context.
66+
* <p>If this constructor is used, this mapping will detect all
67+
* {@link RouterFunction} instances available in the application context.
6768
*/
6869
public RouterFunctionMapping() {
6970
}
@@ -127,7 +128,7 @@ public void afterPropertiesSet() throws Exception {
127128
* Detect a all {@linkplain RouterFunction router functions} in the
128129
* current application context.
129130
*/
130-
@SuppressWarnings({"unchecked", "rawtypes"})
131+
@SuppressWarnings({"rawtypes", "unchecked"})
131132
private void initRouterFunction() {
132133
ApplicationContext applicationContext = obtainApplicationContext();
133134
Map<String, RouterFunction> beans =

0 commit comments

Comments
 (0)