mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
IDEA-166814 Stream API migration: support more post-loop steps
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public static LinkedList<String> test(String[] args) {
|
||||
return Arrays.stream(args).filter(s -> !s.isEmpty()).distinct().sorted().collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static String[] test(String[] args) {
|
||||
return Arrays.stream(args).filter(s -> !s.isEmpty()).distinct().sorted().toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static void test(String[] args) {
|
||||
System.out.println(Arrays.toString(Arrays.stream(args).filter(s -> !s.isEmpty()).distinct().sorted(String.CASE_INSENSITIVE_ORDER).toArray(String[]::new)));
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static String[] test(String[] args) {
|
||||
return Arrays.stream(args).filter(s -> !s.isEmpty()).distinct().sorted().toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static LinkedList<String> test(String[] args) {
|
||||
Set<String> set = new HashSet<>();
|
||||
for(String s : ar<caret>gs) {
|
||||
if(!s.isEmpty())
|
||||
set.add(s);
|
||||
}
|
||||
List<String> list = new ArrayList<>(set);
|
||||
list.sort(null);
|
||||
return new LinkedList<>(list);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static String[] test(String[] args) {
|
||||
Set<String> set = new HashSet<>();
|
||||
for(String s : a<caret>rgs) {
|
||||
if(!s.isEmpty())
|
||||
set.add(s);
|
||||
}
|
||||
List<String> list = new ArrayList<>(set);
|
||||
list.sort(null);
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static void test(String[] args) {
|
||||
Set<String> set = new HashSet<>();
|
||||
for(String s : ar<caret>gs) {
|
||||
if(!s.isEmpty())
|
||||
set.add(s);
|
||||
}
|
||||
List<String> list = new LinkedList<>(set);
|
||||
list.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
System.out.println(Arrays.toString(list.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "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 TreeSet<>(list);
|
||||
return set.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user