Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2017-09-01 15:11:05 +03:00
75 changed files with 1609 additions and 321 deletions
@@ -0,0 +1,10 @@
// "Extract intermediate operations" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
other.stream().filter(s -> s.length() > 2).forEach(System.out::println);
}
}
@@ -0,0 +1,12 @@
// "Extract intermediate operations" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
// c1
//c2
other.stream().filter(s -> s.length() > 2).forEach(System.out::println);
}
}
@@ -0,0 +1,10 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test(List<String> strs) {
List<String> other = strs.stream().filter(s -> s.length() > 2).collect(Collectors.toList());
}
}
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test() {
List<String> strs;
List<String> other = new ArrayList<>();
strs = other.stream().collect(Collectors.toList());
}
}
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test() {
List<String> strs;
List<String> other = new ArrayList<>();
strs = other.stream().filter(s -> s.length() > 2).collect(Collectors.toList());
}
}
@@ -0,0 +1,10 @@
// "Replace with toArray" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
String[] arr = other.stream().filter(s -> s.length() > 2).sorted(String.CASE_INSENSITIVE_ORDER).toArray();
}
}
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test() {
List<String> strs;
List<String> other = new ArrayList<>();
strs = other.stream().filter(s -> s.length() > 2).sorted(String::compareTo).collect(Collectors.toList());
}
}
@@ -0,0 +1,10 @@
// "Extract intermediate operations" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
other.stream().filter(s -> s.length() > 2).forEachOrdered(System.out::println);
}
}
@@ -0,0 +1,10 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test(List<String> other) {
List<String> strs = other.stream().collect(Collectors.toList());
}
}
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test() {
List<String> strs;
List<String> other = new ArrayList<>();
strs = other.stream().collect(Collectors.toList());
}
}
@@ -0,0 +1,10 @@
// "Replace with count()" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
int count = (int) strs.stream().count();
}
}
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
String sb = strs.stream().collect(Collectors.joining());
}
}
@@ -0,0 +1,9 @@
// "Replace with toArray" "true"
import java.util.*;
public class Main {
private void test(List<String> strs) {
String[] arr = strs.toArray();
}
}
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
HashMap<Integer, String> map = other.stream().collect(Collectors.toMap(String::length, s -> s, (a, b) -> a, HashMap::new));
}
}
@@ -0,0 +1,12 @@
// "Extract intermediate operations" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> {
if(s.length() > 2) System.out.println(s);
});
}
}
@@ -0,0 +1,12 @@
// "Extract intermediate operations" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> { // c1
if(s.length() > 2) System.out.println(s); //c2
});
}
}
@@ -0,0 +1,14 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test(List<String> strs) {
List<String> other = new ArrayList<>();
strs.stream().forEac<caret>h(s -> {
if(s.length() > 2) {
other.add(s);
}
});
}
}
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> {strs.add(s)});
}
}
@@ -0,0 +1,13 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> {
if(s.length() > 2) strs.add(s);
});
}
}
@@ -0,0 +1,17 @@
// "Replace with toArray" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> {
if(s.length() > 2) {
strs.add(s);
}
});
String[] arr = strs.toArray();
Arrays.sort(arr, String.CASE_INSENSITIVE_ORDER);
}
}
@@ -0,0 +1,16 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> {
if(s.length() > 2) {
strs.add(s);
}
});
strs.sort(String::compareTo);
}
}
@@ -0,0 +1,10 @@
// "Extract intermediate operations" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
other.stream().forEachOrdere<caret>d(s -> {if(s.length() > 2) System.out.println(s);});
}
}
@@ -0,0 +1,10 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test(List<String> other) {
List<String> strs = new ArrayList<>();
other.stream().forEac<caret>h(s -> {strs.add(s)});
}
}
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
List<String> other = new ArrayList<>();
other.stream().forEac<caret>h(s -> strs.add(s));
}
}
@@ -0,0 +1,11 @@
// "Replace with count()" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
int count = 0;
strs.stream().forEac<caret>h(x -> count++)
}
}
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test() {
List<String> strs = new ArrayList<>();
StringBuilder sb = new StringBuilder();
strs.stream().forEac<caret>h(x -> sb.append(x));
}
}
@@ -0,0 +1,11 @@
// "Replace with toArray" "true"
import java.util.*;
public class Main {
private void test(List<String> strs) {
List<String> tmp = new ArrayList<>();
strs.stream().forEac<caret>h(x -> tmp.add(x));
String[] arr = tmp.toArray();
}
}
@@ -0,0 +1,11 @@
// "Replace with collect" "true"
import java.util.*;
public class Main {
private void test() {
List<String> other = new ArrayList<>();
HashMap<Integer, String> map = new HashMap<Integer, String>();
other.stream().forEac<caret>h(s -> map.putIfAbsent(s.length(), s));
}
}