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:
Sam Brannen
2019-03-14 16:48:44 +01:00
parent 9cf9d0fa21
commit 9d2e7ced89
5 changed files with 10 additions and 14 deletions

View File

@@ -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) {