Java8MapApiInspection: better name generation for lambda argument (IDEA-CR-16359)

This commit is contained in:
Tagir Valeev
2016-11-30 18:20:33 +07:00
parent 0780ecc65b
commit 97f6252f82
5 changed files with 114 additions and 8 deletions
@@ -0,0 +1,21 @@
// "Replace with 'computeIfAbsent' method call" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
static class MyItem {
String k;
int i;
MyItem(String k, int i) {
this.k = k;
this.i = i;
}
}
public MyItem testMap(Map<String, MyItem> map, String localUser) {
MyItem item = map.computeIfAbsent(localUser, u -> new MyItem(u, 1));
return item;
}
}
@@ -0,0 +1,21 @@
// "Replace with 'computeIfAbsent' method call" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
static class MyItem {
String k;
int i;
MyItem(String k, int i) {
this.k = k;
this.i = i;
}
}
public MyItem testMap(Map<String, MyItem> map, String ___1) {
MyItem item = map.computeIfAbsent(___1, k -> new MyItem(k, 1));
return item;
}
}
@@ -0,0 +1,24 @@
// "Replace with 'computeIfAbsent' method call" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
static class MyItem {
String k;
int i;
MyItem(String k, int i) {
this.k = k;
this.i = i;
}
}
public MyItem testMap(Map<String, MyItem> map, String localUser) {
MyItem item = map.get(localUser);
if(item == nul<caret>l) {
map.put(localUser, item = new MyItem(localUser, 1));
}
return item;
}
}
@@ -0,0 +1,24 @@
// "Replace with 'computeIfAbsent' method call" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
static class MyItem {
String k;
int i;
MyItem(String k, int i) {
this.k = k;
this.i = i;
}
}
public MyItem testMap(Map<String, MyItem> map, String ___1) {
MyItem item = map.get(___1);
if(item == nul<caret>l) {
map.put(___1, item = new MyItem(___1, 1));
}
return item;
}
}