mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
Now both options (when unchecked) only disable warning and batch-mode replacement, but the action is still available as an intention.
20 lines
549 B
Java
20 lines
549 B
Java
// "Replace with forEach" "INFORMATION"
|
|
import java.util.*;
|
|
|
|
class A {
|
|
public static void main(String[] args) {
|
|
List<String> names = Arrays.asList("Bob", "Alice", "Bob", "Carol");
|
|
Set<String> uniqNames = new HashSet<>(names.size());
|
|
names.forEach(name -> uniqNames.add(makeNameUnique(name, uniqNames)));
|
|
uniqNames.forEach(System.out::println);
|
|
}
|
|
|
|
private static String makeNameUnique(final String name, final Set<String> uniqNames) {
|
|
if (uniqNames.contains(name)) {
|
|
return name + "1";
|
|
}
|
|
return name;
|
|
}
|
|
|
|
|
|
} |