Files
openide/java/java-tests/testData/inspection/java8MapApi/beforeComputeNotSiblingStatements.java
Daria Nikolskaia dd7f92d48a IDEA-200789: Suggest to use Map.compute() instead of Map.get() + Map.put()
(cherry picked from commit 484148216a2c29613043695ef3f69238118946a9)

IJ-CR-117655

GitOrigin-RevId: 8a95550370e3ee03ec02420254fe2e2287eedf51
2023-10-30 20:55:19 +00:00

10 lines
258 B
Java

// "Replace with 'compute' method call" "false"
import java.util.Map;
public class Main {
public void testCompute(Map<String, Integer> map, String key) {
Integer value = map.get(key);
%
map.pu<caret>t(key, value == null ? 0 : value + 1);
}
}