Favor Math.[min|max]() over handcrafted code
In line with the general trend toward favoring core JDK APIs for common tasks in Spring Framework 5.2, this commit replaces handcrafted statements with Math.min() and Math.max() were applicable.
This commit is contained in:
@@ -288,7 +288,7 @@ class ConstructorResolver {
|
||||
}
|
||||
|
||||
private Object instantiate(
|
||||
String beanName, RootBeanDefinition mbd, Constructor constructorToUse, Object[] argsToUse) {
|
||||
String beanName, RootBeanDefinition mbd, Constructor<?> constructorToUse, Object[] argsToUse) {
|
||||
|
||||
try {
|
||||
InstantiationStrategy strategy = this.beanFactory.getInstantiationStrategy();
|
||||
@@ -933,7 +933,7 @@ class ConstructorResolver {
|
||||
// Decrease raw weight by 1024 to prefer it over equal converted weight.
|
||||
int typeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.arguments);
|
||||
int rawTypeDiffWeight = MethodInvoker.getTypeDifferenceWeight(paramTypes, this.rawArguments) - 1024;
|
||||
return (rawTypeDiffWeight < typeDiffWeight ? rawTypeDiffWeight : typeDiffWeight);
|
||||
return Math.min(rawTypeDiffWeight, typeDiffWeight);
|
||||
}
|
||||
|
||||
public int getAssignabilityWeight(Class<?>[] paramTypes) {
|
||||
|
||||
Reference in New Issue
Block a user