mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-17 20:11:25 +07:00
StreamToLoop tests grouped
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
@@ -10,7 +11,28 @@ public class Main {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public static Map<Integer, String> testMerge(List<String> strings) {
|
||||
return strings.stream().filter(s -> !s.isEmpty())
|
||||
.collect(Collectors.toMap(String::length, Function.identity(), String::concat));
|
||||
}
|
||||
|
||||
public static TreeMap<Integer, String> testPut(List<String> strings) {
|
||||
return strings.stream().filter(s -> !s.isEmpty())
|
||||
.collect(Collectors.toMap(String::length, String::trim, (s, string) -> string, TreeMap::new));
|
||||
}
|
||||
|
||||
public static TreeMap<Integer, String> testSupplier(List<String> strings) {
|
||||
return strings.stream().filter(s -> !s.isEmpty())
|
||||
.collect(Collectors.toMap(String::length, s -> s, (s, string) -> s, TreeMap::new));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(testMerge(Arrays.asList()));
|
||||
System.out.println(testMerge(Arrays.asList("a", "bbb", "cc", "d", "eee", "")));
|
||||
System.out.println(testPut(Arrays.asList()));
|
||||
System.out.println(testPut(Arrays.asList("a", "bbb", "cc", "d", "eee", "")));
|
||||
System.out.println(testSupplier(Arrays.asList()));
|
||||
System.out.println(testSupplier(Arrays.asList("a", "bbb", "cc", "d", "eee", "")));
|
||||
System.out.println(test(Arrays.asList()));
|
||||
System.out.println(test(Arrays.asList("a", "bbb", "cc", "d", "eee", "")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user