mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
support min/max in stream api migration, rearrange tests
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private List<String> test(String[] list, int limit) {
|
||||
List<String> result;
|
||||
List<String> other = new ArrayList<>();
|
||||
System.out.println("hello");
|
||||
result = Arrays.stream(list).filter(Objects::nonNull).limit(limit).map(s -> s + s).sorted().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).filter(entry -> entry.getValue().stream().anyMatch(str -> str.contains("foo"))).limit(limit).map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+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()).filter(str -> str.contains("foo")).limit(limit).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).limit(100).count();
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array, long limit) {
|
||||
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).limit(limit + 1).count();
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).limit(102).count();
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).limit(100).count();
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
public String test(String[] array) {
|
||||
return Arrays.stream(array).limit(11).filter(Objects::nonNull).findFirst().orElse("");
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public Set<String> test(String[] array) {
|
||||
Set<String> set = Arrays.stream(array).filter(Objects::nonNull).limit(10).collect(Collectors.toSet());
|
||||
return set;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public List<String> test(String[] data) {
|
||||
int top = Math.min(10, data.length);
|
||||
List<String> result = Arrays.stream(data).limit(10).map(String::trim).filter(item -> !item.isEmpty()).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
private List<String> test(String[] list, int limit) {
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
System.out.println("hello");
|
||||
for(String s : li<caret>st) {
|
||||
if (s == null) {
|
||||
continue;
|
||||
}
|
||||
result.add(s+s);
|
||||
if(result.size() != limit) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
result.sort(null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// "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(str.contains("foo")) {
|
||||
list.add(entry.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(list.size() >= limit) break;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+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(str.contains("foo")) {
|
||||
list.add(str);
|
||||
}
|
||||
if(list.size() >= limit) return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// "Replace with collect" "false"
|
||||
|
||||
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(str.contains("foo")) {
|
||||
list.add(str);
|
||||
}
|
||||
}
|
||||
if(list.size() >= limit) return list;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// "Replace with collect" "false"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private Set<String> test(String[] list, int limit) {
|
||||
Set<String> result = new HashSet<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
System.out.println("hello");
|
||||
for(String s : li<caret>st) {
|
||||
if (s == null) {
|
||||
continue;
|
||||
}
|
||||
result.add(s+s);
|
||||
if(result.size() != limit) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
result.sort(null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Replace with collect" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
private List<String> test(String[] list, int limit) {
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
System.out.println("hello");
|
||||
for(String s : li<caret>st) {
|
||||
if (s == null) {
|
||||
continue;
|
||||
}
|
||||
result.add(s+s);
|
||||
if(other.size() != limit) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
result.sort(null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
String trimmed = str.trim();
|
||||
if(trimmed.length() > 10) {
|
||||
longStrings = longStrings + 1;
|
||||
if(longStrings >= 100) break;
|
||||
}
|
||||
}
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array, long limit) {
|
||||
long longStrings = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
String trimmed = str.trim();
|
||||
if(trimmed.length() > 10) {
|
||||
longStrings++;
|
||||
if(longStrings > limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
String trimmed = str.trim();
|
||||
if(trimmed.length() > 10) {
|
||||
if(longStrings++ > 100) break;
|
||||
}
|
||||
}
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
String trimmed = str.trim();
|
||||
if(trimmed.length() > 10) {
|
||||
if(100 > ++longStrings) continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with count()" "false"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long longStrings = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
String trimmed = str.trim();
|
||||
if(trimmed.length() > 10) {
|
||||
longStrings = longStrings + 1;
|
||||
if(longStrings >= trimmed.length()) break;
|
||||
}
|
||||
}
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
public class Main {
|
||||
public String test(String[] array) {
|
||||
int count = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
if(++count > 10) return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public Set<String> test(String[] array) {
|
||||
int count = 0;
|
||||
Set<String> set = new HashSet<>();
|
||||
for(String str : a<caret>rray) {
|
||||
if (str != null) {
|
||||
set.add(str);
|
||||
if(++count == 10) break;
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public List<String> test(String[] data) {
|
||||
int top = Math.min(10, data.length);
|
||||
List<String> result = new ArrayList<>();
|
||||
for(int<caret> i=0; i<top; i++) {
|
||||
String item = data[i].trim();
|
||||
if(!item.isEmpty()) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user