Files
openide/java/java-tests/testData/inspection/java8MapApi/beforeComputeIfAbsentSingleLine.java
Tagir Valeev c0f0d3c636 IDEA-174151 'Replace with single Map method' suggests incorrect rewrites to computeIfAbsent
Option added (on by default) to disable warning if side effects are possible.
2017-06-08 17:41:44 +07:00

14 lines
396 B
Java

// "Replace with 'computeIfAbsent' method call" "GENERIC_ERROR_OR_WARNING"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
public void testMap(Map<String, List<String>> map, String key, String value) {
List<String> list = map.get(key);
if(list == nul<caret>l) {
map.put(key, list = new ArrayList<>());
}
list.add(value);
}
}