Polish containsAny of CollectionUtils by reusing findFirstMatch

This commit is contained in:
陈其苗
2020-03-05 10:44:36 +08:00
committed by Rossen Stoyanchev
parent c8c1e61c0a
commit 6013591fac

View File

@@ -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;
}
/**