Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -447,6 +447,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is1xxInformational() {
|
||||
@@ -457,6 +458,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is2xxSuccessful() {
|
||||
@@ -467,6 +469,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#REDIRECTION}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is3xxRedirection() {
|
||||
@@ -477,6 +480,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is4xxClientError() {
|
||||
@@ -487,6 +491,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is5xxServerError() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -166,7 +166,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.status));
|
||||
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.status));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ClientHttpResponseDecorator implements ClientHttpResponse {
|
||||
|
||||
|
||||
private final ClientHttpResponse delegate;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ClientHttpResponseDecorator implements ClientHttpResponse {
|
||||
}
|
||||
|
||||
|
||||
// ServerHttpResponse delegation methods...
|
||||
// ClientHttpResponse delegation methods...
|
||||
|
||||
@Override
|
||||
public HttpStatus getStatusCode() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,8 @@ import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
/**
|
||||
* Resolves method parameters by delegating to a list of registered {@link HandlerMethodArgumentResolver}s.
|
||||
* Resolves method parameters by delegating to a list of registered
|
||||
* {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
|
||||
* Previously resolved method parameters are cached for faster lookups.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -57,28 +58,24 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given {@link HandlerMethodArgumentResolver}s.
|
||||
* Add the given {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
|
||||
* @since 4.3
|
||||
*/
|
||||
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable HandlerMethodArgumentResolver... resolvers) {
|
||||
if (resolvers != null) {
|
||||
for (HandlerMethodArgumentResolver resolver : resolvers) {
|
||||
this.argumentResolvers.add(resolver);
|
||||
}
|
||||
Collections.addAll(this.argumentResolvers, resolvers);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given {@link HandlerMethodArgumentResolver}s.
|
||||
* Add the given {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
|
||||
*/
|
||||
public HandlerMethodArgumentResolverComposite addResolvers(
|
||||
@Nullable List<? extends HandlerMethodArgumentResolver> resolvers) {
|
||||
|
||||
if (resolvers != null) {
|
||||
for (HandlerMethodArgumentResolver resolver : resolvers) {
|
||||
this.argumentResolvers.add(resolver);
|
||||
}
|
||||
this.argumentResolvers.addAll(resolvers);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -100,17 +97,20 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
|
||||
|
||||
/**
|
||||
* Whether the given {@linkplain MethodParameter method parameter} is supported by any registered
|
||||
* {@link HandlerMethodArgumentResolver}.
|
||||
* Whether the given {@linkplain MethodParameter method parameter} is
|
||||
* supported by any registered {@link HandlerMethodArgumentResolver}.
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return (getArgumentResolver(parameter) != null);
|
||||
return getArgumentResolver(parameter) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over registered {@link HandlerMethodArgumentResolver}s and invoke the one that supports it.
|
||||
* @throws IllegalStateException if no suitable {@link HandlerMethodArgumentResolver} is found.
|
||||
* Iterate over registered
|
||||
* {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers} and
|
||||
* invoke the one that supports it.
|
||||
* @throws IllegalStateException if no suitable
|
||||
* {@link HandlerMethodArgumentResolver} is found.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -119,23 +119,21 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
|
||||
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
|
||||
if (resolver == null) {
|
||||
throw new IllegalArgumentException("Unknown parameter type [" + parameter.getParameterType().getName() + "]");
|
||||
throw new IllegalArgumentException("Unsupported parameter type [" +
|
||||
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
|
||||
}
|
||||
return resolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a registered {@link HandlerMethodArgumentResolver} that supports the given method parameter.
|
||||
* Find a registered {@link HandlerMethodArgumentResolver} that supports
|
||||
* the given method parameter.
|
||||
*/
|
||||
@Nullable
|
||||
private HandlerMethodArgumentResolver getArgumentResolver(MethodParameter parameter) {
|
||||
HandlerMethodArgumentResolver result = this.argumentResolverCache.get(parameter);
|
||||
if (result == null) {
|
||||
for (HandlerMethodArgumentResolver methodArgumentResolver : this.argumentResolvers) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Testing if argument resolver [" + methodArgumentResolver + "] supports [" +
|
||||
parameter.getGenericParameterType() + "]");
|
||||
}
|
||||
if (methodArgumentResolver.supportsParameter(parameter)) {
|
||||
result = methodArgumentResolver;
|
||||
this.argumentResolverCache.put(parameter, result);
|
||||
|
||||
Reference in New Issue
Block a user