IDEA-207874 Inspection to replace Map.keySet().contains(K) with Map.containsKey(K)

This commit is contained in:
Tagir Valeev
2019-03-12 13:54:25 +07:00
parent 669f4ee67a
commit 77b6a04c45
5 changed files with 85 additions and 0 deletions
@@ -0,0 +1,10 @@
// "Replace with 'Map.containsKey()'" "true"
import java.util.Map;
class Test {
void test(Map<String, String> map, String key) {
if(map.containsKey(key)) {
System.out.println("contains");
}
}
}
@@ -0,0 +1,10 @@
// "Replace with 'Map.containsValue()'" "true"
import java.util.Map;
class Test {
void test(Map<String, String> map, String key) {
if(map.containsValue(key)) {
System.out.println("contains");
}
}
}
@@ -0,0 +1,10 @@
// "Replace with 'Map.containsKey()'" "true"
import java.util.Map;
class Test {
void test(Map<String, String> map, String key) {
if(map.keySet().cont<caret>ains(key)) {
System.out.println("contains");
}
}
}
@@ -0,0 +1,10 @@
// "Replace with 'Map.containsValue()'" "true"
import java.util.Map;
class Test {
void test(Map<String, String> map, String key) {
if(map.values().cont<caret>ains(key)) {
System.out.println("contains");
}
}
}