Browse Source

Simplify Comparator using method references

See gh-27102
pull/27125/head
diguage 4 years ago committed by Stephane Nicoll
parent
commit
f39c6d36c7
  1. 7
      spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java

7
spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java

@ -19,6 +19,7 @@ package org.springframework.expression.spel.support; @@ -19,6 +19,7 @@ package org.springframework.expression.spel.support;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.springframework.core.MethodParameter;
@ -59,11 +60,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver { @@ -59,11 +60,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
Class<?> type = context.getTypeLocator().findType(typeName);
Constructor<?>[] ctors = type.getConstructors();
Arrays.sort(ctors, (c1, c2) -> {
int c1pl = c1.getParameterCount();
int c2pl = c2.getParameterCount();
return Integer.compare(c1pl, c2pl);
});
Arrays.sort(ctors, Comparator.comparingInt(Constructor::getParameterCount));
Constructor<?> closeMatch = null;
Constructor<?> matchRequiringConversion = null;

Loading…
Cancel
Save