Merge pull request #27102 from diguage
* pr/27102: Update copyright year of changed file Simplify Comparator using method references Closes gh-27102
This commit is contained in:
commit
048954dc1d
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.expression.spel.support;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
|
|
@ -59,11 +60,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
|
||||||
Class<?> type = context.getTypeLocator().findType(typeName);
|
Class<?> type = context.getTypeLocator().findType(typeName);
|
||||||
Constructor<?>[] ctors = type.getConstructors();
|
Constructor<?>[] ctors = type.getConstructors();
|
||||||
|
|
||||||
Arrays.sort(ctors, (c1, c2) -> {
|
Arrays.sort(ctors, Comparator.comparingInt(Constructor::getParameterCount));
|
||||||
int c1pl = c1.getParameterCount();
|
|
||||||
int c2pl = c2.getParameterCount();
|
|
||||||
return Integer.compare(c1pl, c2pl);
|
|
||||||
});
|
|
||||||
|
|
||||||
Constructor<?> closeMatch = null;
|
Constructor<?> closeMatch = null;
|
||||||
Constructor<?> matchRequiringConversion = null;
|
Constructor<?> matchRequiringConversion = null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue