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:
Stephane Nicoll 2021-07-02 08:12:29 +02:00
commit 048954dc1d
1 changed files with 3 additions and 6 deletions

View File

@ -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");
* 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.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 {
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;