mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
[java-inspections] UseBulkOperationInspection: support Maps (IDEA-262786)
GitOrigin-RevId: 9aae98c287f6e2057b09bfda78fb007ba45eeee6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
480de17a92
commit
f68f593aa4
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
result.putAll(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
result.putAll(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
result.putAll(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
result.putAll(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
result.putAll(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
result.putAll(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
map.entrySet().forEach(e -> result<caret>.put(e.getKey(), e.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
map.forEach((key, value) -> result<caret>.put(key, value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
for (Map.Entry<String, Integer> e : map.entrySet()) {
|
||||
result<caret>.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
map.forEach(result::put<caret>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
for (Iterator<Map.Entry<String, Integer>> iterator = map.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Map.Entry<String, Integer> e = iterator.next();
|
||||
result<caret>.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace iteration with bulk 'Map.putAll' call" "true"
|
||||
import java.util.*;
|
||||
|
||||
class Main {
|
||||
void test(Map<String, Integer> map) {
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("answer", 42);
|
||||
Iterator<Map.Entry<String, Integer>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Integer> e = iterator.next();
|
||||
result<caret>.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user