Browse Source

Polish containsAny of CollectionUtils by reusing findFirstMatch

pull/24691/head
陈其苗 6 years ago committed by Rossen Stoyanchev
parent
commit
6013591fac
  1. 10
      spring-core/src/main/java/org/springframework/util/CollectionUtils.java

10
spring-core/src/main/java/org/springframework/util/CollectionUtils.java

@ -181,15 +181,7 @@ public abstract class CollectionUtils { @@ -181,15 +181,7 @@ public abstract class CollectionUtils {
* @return whether any of the candidates has been found
*/
public static boolean containsAny(Collection<?> source, Collection<?> candidates) {
if (isEmpty(source) || isEmpty(candidates)) {
return false;
}
for (Object candidate : candidates) {
if (source.contains(candidate)) {
return true;
}
}
return false;
return findFirstMatch(source, candidates) != null;
}
/**

Loading…
Cancel
Save