mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
support min/max in stream api migration, rearrange tests
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<String> list) {
|
||||
List<String> result = list.stream().distinct().filter(s -> !s.contains("foo")).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(Map<String, List<String>> map, int limit) {
|
||||
List<String> list = map.entrySet().stream().filter(entry -> entry.getValue() != null).flatMap(entry -> entry.getValue().stream()).distinct().limit(limit).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with toArray" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
String[] test(List<String> list) {
|
||||
return list.stream().filter(Objects::nonNull).sorted(String.CASE_INSENSITIVE_ORDER).toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).toArray();
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
Object[] arr;
|
||||
arr = data.stream().filter(str -> !str.isEmpty()).toArray();
|
||||
System.out.println(Arrays.toString(arr));
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<Integer> ints) {
|
||||
long[] arr = ints.stream().mapToLong(anInt -> anInt).toArray();
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Test {
|
||||
public void test(int bound) {
|
||||
Object[] arr = IntStream.range(0, bound).boxed().toArray(Integer[]::new);
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Test {
|
||||
public void test(int bound) {
|
||||
Integer[][] arr = IntStream.range(0, bound).mapToObj(i -> new Integer[]{i}).toArray(Integer[][]::new);
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<List<String>> list) {
|
||||
List<?>[] arr = list.toArray(new List[0]);
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
Object[] arr = data.stream().filter(str -> !str.isEmpty()).toArray();
|
||||
System.out.println(Arrays.toString(arr));
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public List<?>[] testToArray(List<String> data) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).map(Collections::singletonList).distinct().toArray(List<?>[]::new);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String[] testToArray(List<String> data) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).distinct().toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public CharSequence[] testToArray(List<String> data) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).distinct().toArray(CharSequence[]::new);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String[] testToArray(List<String> data) {
|
||||
Set<String> result = new LinkedHashSet<>();
|
||||
if(!data.isEmpty()) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).map(String::trim).distinct().toArray(String[]::new);
|
||||
}
|
||||
result.add("None");
|
||||
return result.toArray(new String[1]);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static String[] test(String[] args) {
|
||||
String[] array = Arrays.stream(args).filter(s -> !s.isEmpty()).distinct().sorted(String.CASE_INSENSITIVE_ORDER).toArray(String[]::new);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).distinct().sorted().toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String[][] testToArray(List<String> data) {
|
||||
return data.stream().filter(str -> !str.isEmpty()).map(str -> new String[]{str}).toArray(String[][]::new);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<String> list) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for(String s : li<caret>st) {
|
||||
if(result.contains(s)) {
|
||||
continue;
|
||||
}
|
||||
if(s.contains("foo")) {
|
||||
continue;
|
||||
}
|
||||
result.add(s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Main {
|
||||
List<String> test(Map<String, List<String>> map, int limit) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Map.Entry<String, List<String>> entry : map.<caret>entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
for(String str : entry.getValue()) {
|
||||
if (!list.contains(str)) {
|
||||
list.add(str);
|
||||
}
|
||||
if (list.size() >= limit) return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Replace with collect" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<String> list) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String s : li<caret>st) {
|
||||
if (result.contains(s)) {
|
||||
continue;
|
||||
}
|
||||
if (s.contains("foo")) {
|
||||
continue;
|
||||
}
|
||||
result.add(s + s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with toArray" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
String[] test(List<String> list) {
|
||||
List<String> result = new LinkedList<>();
|
||||
for(String str : li<caret>st) {
|
||||
if(str != null) {
|
||||
result.add(str);
|
||||
}
|
||||
}
|
||||
result.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
return result.toArray();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
Object[] arr;
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
arr = result.toArray();
|
||||
System.out.println(Arrays.toString(arr));
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<Integer> ints) {
|
||||
long[] arr = new long[ints.size()];
|
||||
for(int <caret>i = 0; i < ints.size(); i++) {
|
||||
arr[i] = ints.get(i);
|
||||
}
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Test {
|
||||
public void test(int bound) {
|
||||
Object[] arr = new Integer[bound];
|
||||
for(int <caret>i = 0; i < bound; i++) {
|
||||
arr[i] = i;
|
||||
}
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Test {
|
||||
public void test(int bound) {
|
||||
Integer[][] arr = new Integer[bound][];
|
||||
for(int <caret>i = 0; i < arr.length; i++) {
|
||||
arr[i] = new Integer[] {i};
|
||||
}
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<List<String>> list) {
|
||||
List<?>[] arr = new List[list.size()];
|
||||
for(i<caret>nt i = 0; i < arr.length; i++) {
|
||||
arr[i] = list.get(i);
|
||||
}
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
Object[] arr = result.toArray();
|
||||
System.out.println(Arrays.toString(arr));
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with toArray" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
Object[] arr = result.toArray();
|
||||
System.out.println(result);
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public List<?>[] testToArray(List<String> data) {
|
||||
Set<List<String>> result = new LinkedHashSet<>();
|
||||
for (String str : dat<caret>a) {
|
||||
if (!str.isEmpty()) {
|
||||
List<String> list = Collections.singletonList(str);
|
||||
result.add(list);
|
||||
}
|
||||
}
|
||||
return result.toArray(new List<?>[0]);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String[] testToArray(List<String> data) {
|
||||
Set<String> result = new HashSet<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with toArray" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
Set<String> result = new IdentityHashSet<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
return result.toArray();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public CharSequence[] testToArray(List<String> data) {
|
||||
Set<String> result = new LinkedHashSet<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
return result.toArray(new CharSequence[result.size()]);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String[] testToArray(List<String> data) {
|
||||
Set<String> result = new LinkedHashSet<>();
|
||||
if(!data.isEmpty()) {
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty()) {
|
||||
result.add(str.trim());
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
result.add("None");
|
||||
return result.toArray(new String[1]);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static String[] test(String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for(String s : ar<caret>gs) {
|
||||
if(!s.isEmpty())
|
||||
list.add(s);
|
||||
}
|
||||
Set<String> set = new HashSet<>(list);
|
||||
String[] array = set.toArray(new String[set.size()]);
|
||||
Arrays.sort(array, String.CASE_INSENSITIVE_ORDER);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
Set<String> result = new TreeSet<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public String[][] testToArray(List<String> data) {
|
||||
List<String[]> result = new ArrayList<>();
|
||||
for (String str : dat<caret>a) {
|
||||
if (!str.isEmpty()) {
|
||||
String[] arr = {str};
|
||||
result.add(arr);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[result.size()][]);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with toArray" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public Object[] testToArray(List<String> data) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String str : d<caret>ata) {
|
||||
if (!str.isEmpty())
|
||||
result.add(str);
|
||||
}
|
||||
return result.toArray(new String[10]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user