mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
IDEA-165063 Stream API migration: support simple limit conversions
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;
|
||||
}
|
||||
}
|
||||
+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(100).count();
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+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" "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;
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user