collection.add(x)) could be
replaced when calling a bulk method (e.g. collection.addAll(listOfX). It's
not only shorter but in some cases may be more performant as well.
Example:
void test(Collection<Integer> numbers) {
List<Integer> result = new ArrayList<>();
for (Integer i : numbers) {
result.add(i);
}
}
After the fix is applied, the result will be like this:
void test(Collection<Integer> numbers) {
List<Integer> result = new ArrayList<>();
result.addAll(numbers);
}
Use the checkbox below to warn even if the original code iterates over an array while
bulk method requires a Collection. In this case the quick-fix action will
automatically wrap an array with Arrays.asList() call.
New in 2017.1