Skip to content

Commit 215caed

Browse files
committed
Polishing
1 parent 7465878 commit 215caed

File tree

11 files changed

+145
-137
lines changed

11 files changed

+145
-137
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -279,7 +279,7 @@ public void setContainingClass(Class<?> containingClass) {
279279
}
280280

281281
/**
282-
* Build a ResolvableType object for the wrapped parameter/field.
282+
* Build a {@link ResolvableType} object for the wrapped parameter/field.
283283
* @since 4.0
284284
*/
285285
public ResolvableType getResolvableType() {

spring-context/src/main/java/org/springframework/validation/ObjectError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -144,7 +144,7 @@ public boolean equals(@Nullable Object other) {
144144

145145
@Override
146146
public int hashCode() {
147-
return super.hashCode() * 29 + getObjectName().hashCode();
147+
return (29 * super.hashCode() + getObjectName().hashCode());
148148
}
149149

150150
@Override

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ protected boolean destinationEquals(DestinationCacheKey otherKey) {
522522
public boolean equals(Object other) {
523523
// Effectively checking object equality as well as toString equality.
524524
// On WebSphere MQ, Destination objects do not implement equals...
525-
return (this == other || destinationEquals((DestinationCacheKey) other));
525+
return (this == other || (other instanceof DestinationCacheKey &&
526+
destinationEquals((DestinationCacheKey) other)));
526527
}
527528

528529
@Override
@@ -590,7 +591,7 @@ public boolean equals(Object other) {
590591

591592
@Override
592593
public int hashCode() {
593-
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector);
594+
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector));
594595
}
595596

596597
@Override

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@
2828

2929
/**
3030
* Resolves method parameters by delegating to a list of registered
31-
* {@link HandlerMethodArgumentResolver}. Previously resolved method parameters are cached
32-
* for faster lookups.
31+
* {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
32+
* Previously resolved method parameters are cached for faster lookups.
3333
*
3434
* @author Rossen Stoyanchev
3535
* @author Juergen Hoeller
@@ -52,28 +52,24 @@ public HandlerMethodArgumentResolverComposite addResolver(HandlerMethodArgumentR
5252
}
5353

5454
/**
55-
* Add the given {@link HandlerMethodArgumentResolver}s.
55+
* Add the given {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
5656
* @since 4.3
5757
*/
5858
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable HandlerMethodArgumentResolver... resolvers) {
5959
if (resolvers != null) {
60-
for (HandlerMethodArgumentResolver resolver : resolvers) {
61-
this.argumentResolvers.add(resolver);
62-
}
60+
Collections.addAll(this.argumentResolvers, resolvers);
6361
}
6462
return this;
6563
}
6664

6765
/**
68-
* Add the given {@link HandlerMethodArgumentResolver}s.
66+
* Add the given {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
6967
*/
7068
public HandlerMethodArgumentResolverComposite addResolvers(
7169
@Nullable List<? extends HandlerMethodArgumentResolver> argumentResolvers) {
7270

7371
if (argumentResolvers != null) {
74-
for (HandlerMethodArgumentResolver resolver : argumentResolvers) {
75-
this.argumentResolvers.add(resolver);
76-
}
72+
this.argumentResolvers.addAll(argumentResolvers);
7773
}
7874
return this;
7975
}
@@ -94,30 +90,35 @@ public void clear() {
9490

9591

9692
/**
97-
* Whether the given {@linkplain MethodParameter method parameter} is supported by any registered
98-
* {@link HandlerMethodArgumentResolver}.
93+
* Whether the given {@linkplain MethodParameter method parameter} is
94+
* supported by any registered {@link HandlerMethodArgumentResolver}.
9995
*/
10096
@Override
10197
public boolean supportsParameter(MethodParameter parameter) {
10298
return getArgumentResolver(parameter) != null;
10399
}
104100

105101
/**
106-
* Iterate over registered {@link HandlerMethodArgumentResolver}s and invoke the one that supports it.
107-
* @throws IllegalStateException if no suitable {@link HandlerMethodArgumentResolver} is found.
102+
* Iterate over registered
103+
* {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}
104+
* and invoke the one that supports it.
105+
* @throws IllegalStateException if no suitable
106+
* {@link HandlerMethodArgumentResolver} is found.
108107
*/
109108
@Override
110109
@Nullable
111110
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
112111
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
113112
if (resolver == null) {
114-
throw new IllegalStateException("Unknown parameter type [" + parameter.getParameterType().getName() + "]");
113+
throw new IllegalArgumentException("Unsupported parameter type [" +
114+
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
115115
}
116116
return resolver.resolveArgument(parameter, message);
117117
}
118118

119119
/**
120-
* Find a registered {@link HandlerMethodArgumentResolver} that supports the given method parameter.
120+
* Find a registered {@link HandlerMethodArgumentResolver} that supports
121+
* the given method parameter.
121122
*/
122123
@Nullable
123124
private HandlerMethodArgumentResolver getArgumentResolver(MethodParameter parameter) {

spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -178,7 +178,7 @@ public boolean equals(@Nullable Object other) {
178178
*/
179179
@Override
180180
public int hashCode() {
181-
return super.hashCode() * 31 + this.resourceBasePath.hashCode();
181+
return (31 * super.hashCode() + this.resourceBasePath.hashCode());
182182
}
183183

184184
/**

spring-web/src/main/java/org/springframework/http/HttpStatus.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -447,6 +447,7 @@ public Series series() {
447447
* Whether this status code is in the HTTP series
448448
* {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}.
449449
* This is a shortcut for checking the value of {@link #series()}.
450+
* @since 4.0
450451
* @see #series()
451452
*/
452453
public boolean is1xxInformational() {
@@ -457,6 +458,7 @@ public boolean is1xxInformational() {
457458
* Whether this status code is in the HTTP series
458459
* {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}.
459460
* This is a shortcut for checking the value of {@link #series()}.
461+
* @since 4.0
460462
* @see #series()
461463
*/
462464
public boolean is2xxSuccessful() {
@@ -467,6 +469,7 @@ public boolean is2xxSuccessful() {
467469
* Whether this status code is in the HTTP series
468470
* {@link org.springframework.http.HttpStatus.Series#REDIRECTION}.
469471
* This is a shortcut for checking the value of {@link #series()}.
472+
* @since 4.0
470473
* @see #series()
471474
*/
472475
public boolean is3xxRedirection() {
@@ -477,6 +480,7 @@ public boolean is3xxRedirection() {
477480
* Whether this status code is in the HTTP series
478481
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
479482
* This is a shortcut for checking the value of {@link #series()}.
483+
* @since 4.0
480484
* @see #series()
481485
*/
482486
public boolean is4xxClientError() {
@@ -487,6 +491,7 @@ public boolean is4xxClientError() {
487491
* Whether this status code is in the HTTP series
488492
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
489493
* This is a shortcut for checking the value of {@link #series()}.
494+
* @since 4.0
490495
* @see #series()
491496
*/
492497
public boolean is5xxServerError() {

spring-web/src/main/java/org/springframework/http/ResponseEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -166,7 +166,7 @@ public boolean equals(@Nullable Object other) {
166166

167167
@Override
168168
public int hashCode() {
169-
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.status));
169+
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.status));
170170
}
171171

172172
@Override

spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @since 5.0
3434
*/
3535
public class ClientHttpResponseDecorator implements ClientHttpResponse {
36-
36+
3737
private final ClientHttpResponse delegate;
3838

3939

@@ -48,7 +48,7 @@ public ClientHttpResponse getDelegate() {
4848
}
4949

5050

51-
// ServerHttpResponse delegation methods...
51+
// ClientHttpResponse delegation methods...
5252

5353
@Override
5454
public HttpStatus getStatusCode() {

spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,7 +31,8 @@
3131
import org.springframework.web.context.request.NativeWebRequest;
3232

3333
/**
34-
* Resolves method parameters by delegating to a list of registered {@link HandlerMethodArgumentResolver}s.
34+
* Resolves method parameters by delegating to a list of registered
35+
* {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
3536
* Previously resolved method parameters are cached for faster lookups.
3637
*
3738
* @author Rossen Stoyanchev
@@ -57,28 +58,24 @@ public HandlerMethodArgumentResolverComposite addResolver(HandlerMethodArgumentR
5758
}
5859

5960
/**
60-
* Add the given {@link HandlerMethodArgumentResolver}s.
61+
* Add the given {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
6162
* @since 4.3
6263
*/
6364
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable HandlerMethodArgumentResolver... resolvers) {
6465
if (resolvers != null) {
65-
for (HandlerMethodArgumentResolver resolver : resolvers) {
66-
this.argumentResolvers.add(resolver);
67-
}
66+
Collections.addAll(this.argumentResolvers, resolvers);
6867
}
6968
return this;
7069
}
7170

7271
/**
73-
* Add the given {@link HandlerMethodArgumentResolver}s.
72+
* Add the given {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
7473
*/
7574
public HandlerMethodArgumentResolverComposite addResolvers(
7675
@Nullable List<? extends HandlerMethodArgumentResolver> resolvers) {
7776

7877
if (resolvers != null) {
79-
for (HandlerMethodArgumentResolver resolver : resolvers) {
80-
this.argumentResolvers.add(resolver);
81-
}
78+
this.argumentResolvers.addAll(resolvers);
8279
}
8380
return this;
8481
}
@@ -100,17 +97,20 @@ public void clear() {
10097

10198

10299
/**
103-
* Whether the given {@linkplain MethodParameter method parameter} is supported by any registered
104-
* {@link HandlerMethodArgumentResolver}.
100+
* Whether the given {@linkplain MethodParameter method parameter} is
101+
* supported by any registered {@link HandlerMethodArgumentResolver}.
105102
*/
106103
@Override
107104
public boolean supportsParameter(MethodParameter parameter) {
108-
return (getArgumentResolver(parameter) != null);
105+
return getArgumentResolver(parameter) != null;
109106
}
110107

111108
/**
112-
* Iterate over registered {@link HandlerMethodArgumentResolver}s and invoke the one that supports it.
113-
* @throws IllegalStateException if no suitable {@link HandlerMethodArgumentResolver} is found.
109+
* Iterate over registered
110+
* {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers} and
111+
* invoke the one that supports it.
112+
* @throws IllegalStateException if no suitable
113+
* {@link HandlerMethodArgumentResolver} is found.
114114
*/
115115
@Override
116116
@Nullable
@@ -119,23 +119,21 @@ public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewC
119119

120120
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
121121
if (resolver == null) {
122-
throw new IllegalArgumentException("Unknown parameter type [" + parameter.getParameterType().getName() + "]");
122+
throw new IllegalArgumentException("Unsupported parameter type [" +
123+
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
123124
}
124125
return resolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
125126
}
126127

127128
/**
128-
* Find a registered {@link HandlerMethodArgumentResolver} that supports the given method parameter.
129+
* Find a registered {@link HandlerMethodArgumentResolver} that supports
130+
* the given method parameter.
129131
*/
130132
@Nullable
131133
private HandlerMethodArgumentResolver getArgumentResolver(MethodParameter parameter) {
132134
HandlerMethodArgumentResolver result = this.argumentResolverCache.get(parameter);
133135
if (result == null) {
134136
for (HandlerMethodArgumentResolver methodArgumentResolver : this.argumentResolvers) {
135-
if (logger.isTraceEnabled()) {
136-
logger.trace("Testing if argument resolver [" + methodArgumentResolver + "] supports [" +
137-
parameter.getGenericParameterType() + "]");
138-
}
139137
if (methodArgumentResolver.supportsParameter(parameter)) {
140138
result = methodArgumentResolver;
141139
this.argumentResolverCache.put(parameter, result);

0 commit comments

Comments
 (0)