mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
MigrateToStreamFix: explicit formatting removed (as formatted anyways automatically)
This commit is contained in:
+1
-1
@@ -5,6 +5,6 @@ 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());
|
||||
List<String> other = strs.stream().filter(s -> s.length() > 2).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
int count = (int) list.stream().filter(s -> !s.isEmpty()).count();
|
||||
int count = (int) list.stream().filter(s -> !s.isEmpty()).count();
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
String longest = list.stream().max(Comparator.comparingInt(String::length)).orElse(null);
|
||||
String longest = list.stream().max(Comparator.comparingInt(String::length)).orElse(null);
|
||||
System.out.println(longest);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> other) {
|
||||
List<String> strs = other.stream().collect(Collectors.toList());
|
||||
List<String> strs = other.stream().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ import java.util.*;
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
int count = (int) strs.stream().count();
|
||||
int count = (int) strs.stream().count();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.Collectors;
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
String sb = strs.stream().collect(Collectors.joining());
|
||||
String sb = strs.stream().collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ 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));
|
||||
HashMap<Integer, String> map = other.stream().collect(Collectors.toMap(String::length, s -> s, (a, b) -> a, HashMap::new));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<String> list) {
|
||||
List<String> result = list.stream().distinct().filter(s -> !s.contains("foo")).collect(Collectors.toList());
|
||||
List<String> result = list.stream().distinct().filter(s -> !s.contains("foo")).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ 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()).distinct().limit(limit).collect(Collectors.toList());
|
||||
List<String> list = map.entrySet().stream().filter(entry -> entry.getValue() != null).flatMap(entry -> entry.getValue().stream()).distinct().limit(limit).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<Integer> ints) {
|
||||
long[] arr = ints.stream().mapToLong(anInt -> anInt).toArray();
|
||||
long[] arr = ints.stream().mapToLong(anInt -> anInt).toArray();
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Test {
|
||||
public void test(int bound) {
|
||||
Object[] arr = IntStream.range(0, bound).boxed().toArray(Integer[]::new);
|
||||
Object[] arr = IntStream.range(0, bound).boxed().toArray(Integer[]::new);
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Test {
|
||||
public void test(int bound) {
|
||||
Integer[][] arr = IntStream.range(0, bound).mapToObj(i -> new Integer[]{i}).toArray(Integer[][]::new);
|
||||
Integer[][] arr = IntStream.range(0, bound).mapToObj(i -> new Integer[]{i}).toArray(Integer[][]::new);
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<List<String>> list) {
|
||||
List<?>[] arr = list.stream().toArray(List[]::new);
|
||||
List<?>[] arr = list.stream().toArray(List[]::new);
|
||||
System.out.println(Arrays.toString(arr));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public void testAssignment(List<String> data) {
|
||||
String found = data.stream().map(String::trim).anyMatch(trimmed -> !trimmed.isEmpty()) ? "yes" : "no";
|
||||
String found = data.stream().map(String::trim).anyMatch(trimmed -> !trimmed.isEmpty()) ? "yes" : "no";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,6 +4,6 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public void testAssignment(List<String> data) {
|
||||
boolean found = data.stream().map(String::trim).anyMatch(trimmed -> !trimmed.isEmpty());
|
||||
boolean found = data.stream().map(String::trim).anyMatch(trimmed -> !trimmed.isEmpty());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,6 +4,6 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public void testAssignment(List<String> data) {
|
||||
boolean found = data.stream().map(String::trim).allMatch(trimmed -> trimmed.isEmpty());
|
||||
boolean found = data.stream().map(String::trim).allMatch(trimmed -> trimmed.isEmpty());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(BufferedReader br) throws IOException {
|
||||
List<String> result = br.lines().map(String::trim).collect(Collectors.toList());
|
||||
List<String> result = br.lines().map(String::trim).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(BufferedReader br) throws IOException {
|
||||
List<String> result = br.lines().map(String::trim).collect(Collectors.toList());
|
||||
List<String> result = br.lines().map(String::trim).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
final double[] array = new double[10];
|
||||
final List<Double> list = Arrays.stream(array).boxed().collect(Collectors.toList());
|
||||
final List<Double> list = Arrays.stream(array).boxed().collect(Collectors.toList());
|
||||
// Cannot be replaced with list.addAll()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public void test(Integer[] arr) {
|
||||
List<Integer> result = Arrays.stream(arr).filter(x -> x > 5).collect(Collectors.toList());
|
||||
List<Integer> result = Arrays.stream(arr).filter(x -> x > 5).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
class A {
|
||||
public static void main(List<String> args) {
|
||||
ArrayList<String> uniqNames = args.stream().map(name -> name.substring(1)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<String> uniqNames = args.stream().map(name -> name.substring(1)).collect(Collectors.toCollection(ArrayList::new));
|
||||
uniqNames.forEach(System.out::println);
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -5,14 +5,14 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = list.stream().map(s -> new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
List<Runnable> result = list.stream().map(s -> new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,6 +10,6 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
List<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<String> names = persons.stream().filter(Objects::nonNull).map(Person::getName).collect(Collectors.toList());
|
||||
List<String> names = persons.stream().filter(Objects::nonNull).map(Person::getName).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
Collection<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
Collection<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
List<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
//some comment
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<String> names = persons.stream().map(person -> "name: " + person.getName()).collect(Collectors.toList());
|
||||
List<String> names = persons.stream().map(person -> "name: " + person.getName()).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public void testPrimitiveMap(List<String> data) {
|
||||
List<Integer> list = data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len > 10).boxed().collect(Collectors.toList());
|
||||
List<Integer> list = data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len > 10).boxed().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> getStrings(List<?> list) {
|
||||
List<String> result = list.stream().filter(o -> o instanceof String).map(o -> (String) o).collect(Collectors.toList());
|
||||
List<String> result = list.stream().filter(o -> o instanceof String).map(o -> (String) o).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main<T> {
|
||||
public static List<Collection<CharSequence>> test(List<String> list) {
|
||||
List<Collection<CharSequence>> strings = list.stream().<List<CharSequence>>map(Collections::singletonList).collect(Collectors.toList());
|
||||
List<Collection<CharSequence>> strings = list.stream().<List<CharSequence>>map(Collections::singletonList).collect(Collectors.toList());
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -6,10 +6,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
void testList(List<String> input) {
|
||||
List<String> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>(/*initial size*/10)));
|
||||
List<String> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>(/*initial size*/10)));
|
||||
System.out.println(result);
|
||||
|
||||
ArrayList<String> result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>/*valuable comment*/(20)));
|
||||
ArrayList<String> result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>/*valuable comment*/(20)));
|
||||
System.out.println(result2);
|
||||
|
||||
// Non-empty
|
||||
@@ -26,10 +26,10 @@ public class Test {
|
||||
}
|
||||
|
||||
void testSet(List<String> input) {
|
||||
Set<String> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new HashSet/*comment*/<>(/*size*/10)));
|
||||
Set<String> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new HashSet/*comment*/<>(/*size*/10)));
|
||||
System.out.println(result);
|
||||
|
||||
Collection<String> result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new LinkedHashSet<>(20, /*load factor*/ 0.8f)));
|
||||
Collection<String> result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new LinkedHashSet<>(20, /*load factor*/ 0.8f)));
|
||||
System.out.println(result2);
|
||||
|
||||
// Non-empty
|
||||
@@ -37,18 +37,18 @@ public class Test {
|
||||
input.stream().filter(s -> !s.isEmpty()).forEach(result3::add);
|
||||
System.out.println(result3);
|
||||
|
||||
Collection<TimeUnit> result4 = input.stream().filter(s -> !s.isEmpty()).map(TimeUnit::valueOf).collect(Collectors.toCollection(() -> EnumSet.noneOf(/*timeunits*/TimeUnit.class)));
|
||||
Collection<TimeUnit> result4 = input.stream().filter(s -> !s.isEmpty()).map(TimeUnit::valueOf).collect(Collectors.toCollection(() -> EnumSet.noneOf(/*timeunits*/TimeUnit.class)));
|
||||
System.out.println(result4);
|
||||
}
|
||||
|
||||
void testMap(List<String> input) {
|
||||
Map<Integer, String> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10)));
|
||||
Map<Integer, String> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10)));
|
||||
System.out.println(result);
|
||||
|
||||
Map<Integer, String> result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10, 0.8f)));
|
||||
Map<Integer, String> result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10, 0.8f)));
|
||||
System.out.println(result2);
|
||||
|
||||
EnumMap<TimeUnit, String> result3 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(TimeUnit::valueOf, s -> s, (a, b) -> b, () -> new EnumMap<>(TimeUnit.class)));
|
||||
EnumMap<TimeUnit, String> result3 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(TimeUnit::valueOf, s -> s, (a, b) -> b, () -> new EnumMap<>(TimeUnit.class)));
|
||||
System.out.println(result3);
|
||||
|
||||
// Non-empty
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ class Lists {
|
||||
|
||||
public class Test {
|
||||
public void test() {
|
||||
List<String> list = IntStream.range(0, 10).filter(i -> i % 2 == 0).mapToObj(String::valueOf).collect(Collectors.toList());
|
||||
List<String> list = IntStream.range(0, 10).filter(i -> i % 2 == 0).mapToObj(String::valueOf).collect(Collectors.toList());
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ class Maps {
|
||||
|
||||
public class Test {
|
||||
public void test() {
|
||||
Map<String, Integer> map = IntStream.range(0, 10).filter(i -> i % 2 == 0).boxed().collect(Collectors.toMap(String::valueOf, i -> i, (a, b) -> b));
|
||||
Map<String, Integer> map = IntStream.range(0, 10).filter(i -> i % 2 == 0).boxed().collect(Collectors.toMap(String::valueOf, i -> i, (a, b) -> b));
|
||||
System.out.println(map);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
Set<String> names = persons.stream().map(Person::getName).collect(Collectors.toSet());
|
||||
Set<String> names = persons.stream().map(Person::getName).collect(Collectors.toSet());
|
||||
/*valuable comment*/
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -5,11 +5,11 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = list.stream().<Runnable>map(s -> () -> {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}).collect(Collectors.toList());
|
||||
List<Runnable> result = list.stream().<Runnable>map(s -> () -> {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,6 +10,6 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
Set<String> names = persons.stream().map(Person::getName).collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
Set<String> names = persons.stream().map(Person::getName).collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<CharSequence> getListCharSequence(List<String> input) {
|
||||
List<CharSequence> result = input.stream().filter(s -> !s.isEmpty()).map(String::trim).collect(Collectors.toList());
|
||||
List<CharSequence> result = input.stream().filter(s -> !s.isEmpty()).map(String::trim).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
MyObj test(List<String> list) {
|
||||
List<String> res = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||
List<String> res = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||
return new MyObj(res);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Main<T> {
|
||||
public static List<String> test() {
|
||||
List<String> strings = IntStream.range(0, 10).<String>mapToObj(x -> null).collect(Collectors.toList());
|
||||
List<String> strings = IntStream.range(0, 10).<String>mapToObj(x -> null).collect(Collectors.toList());
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,6 +10,6 @@ public class Collect {
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<String> names = persons.stream().map(Person::getName).sorted(Comparator.comparing(Person::getName)).collect(Collectors.toList());
|
||||
List<String> names = persons.stream().map(Person::getName).sorted(Comparator.comparing(Person::getName)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Collect {
|
||||
void collectNames(List<String> persons){
|
||||
List<String> names = persons.stream().map(String::toLowerCase).sorted().collect(Collectors.toList());
|
||||
List<String> names = persons.stream().map(String::toLowerCase).sorted().collect(Collectors.toList());
|
||||
// sort
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main<T> {
|
||||
public static List<Collection<String>> test(List<String> list) {
|
||||
List<Collection<String>> strings = list.stream().map(Collections::singletonList).collect(Collectors.toList());
|
||||
List<Collection<String>> strings = list.stream().map(Collections::singletonList).collect(Collectors.toList());
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<String, Integer> test(String... list) {
|
||||
Map<String, Integer> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.toMap(s -> s, s -> 1, (a, b) -> a + b));
|
||||
Map<String, Integer> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.toMap(s -> s, s -> 1, (a, b) -> a + b));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<String, Integer> test(String... list) {
|
||||
HashMap<String, Integer> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.toMap(s -> s, s -> 1, (a, b) -> b, HashMap::new));
|
||||
HashMap<String, Integer> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.toMap(s -> s, s -> 1, (a, b) -> b, HashMap::new));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<String, Integer> test(String... list) {
|
||||
Map<String, Integer> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.toMap(s -> s, s -> 1, (a, b) -> a, LinkedHashMap::new));
|
||||
Map<String, Integer> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.toMap(s -> s, s -> 1, (a, b) -> a, LinkedHashMap::new));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public void testPrimitiveMap(List<String> data) {
|
||||
List<String> list = data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len > 10).mapToObj(String::valueOf).collect(Collectors.toList());
|
||||
List<String> list = data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len > 10).mapToObj(String::valueOf).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, ArrayList<String>> test(String... list) {
|
||||
Map<Integer, ArrayList<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length, Collectors.toCollection(ArrayList::new)));
|
||||
Map<Integer, ArrayList<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length, Collectors.toCollection(ArrayList::new)));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, List<String>> test(String... list) {
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length));
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, List<String>> test(String... list) {
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length, Collectors.mapping(String::trim, Collectors.toCollection(LinkedList::new))));
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length, Collectors.mapping(String::trim, Collectors.toCollection(LinkedList::new))));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, List<String>> test(String... list) {
|
||||
HashMap<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length, HashMap::new, Collectors.mapping(String::trim, Collectors.toList())));
|
||||
HashMap<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length, HashMap::new, Collectors.mapping(String::trim, Collectors.toList())));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.IntStream;
|
||||
public class Main {
|
||||
public void test() {
|
||||
String[] values = {"a", "b", "c"};
|
||||
Map<String, List<Object>> map = IntStream.range(0, values.length).boxed().collect(Collectors.groupingBy(i -> "X" + i, Collectors.mapping(i -> values[i], Collectors.toList())));
|
||||
Map<String, List<Object>> map = IntStream.range(0, values.length).boxed().collect(Collectors.groupingBy(i -> "X" + i, Collectors.mapping(i -> values[i], Collectors.toList())));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, List<String>> test(String... list) {
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length));
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private Map<Integer, List<String>> test(String... list) {
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length));
|
||||
Map<Integer, List<String>> map = Arrays.stream(list).filter(Objects::nonNull).collect(Collectors.groupingBy(String::length));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
Map<Integer, List<String>> test(List<String> list) {
|
||||
Map<Integer, List<String>> map = list.stream().collect(Collectors.groupingBy(String::length));
|
||||
Map<Integer, List<String>> map = list.stream().collect(Collectors.groupingBy(String::length));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
class A {
|
||||
public List<? super Integer> sum() {
|
||||
List<? super Integer> result = IntStream.range(0, 10).mapToObj(i -> i * 2).collect(Collectors.toList());
|
||||
List<? super Integer> result = IntStream.range(0, 10).mapToObj(i -> i * 2).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ public class Main {
|
||||
}
|
||||
|
||||
public long test(List<Person> collection) {
|
||||
long i = collection.stream().filter(Objects::nonNull).mapToLong(Person::getAge).sum();
|
||||
long i = collection.stream().filter(Objects::nonNull).mapToLong(Person::getAge).sum();
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class Main {
|
||||
}
|
||||
|
||||
public long test(List<Person> collection, Person include) {
|
||||
long i = collection.stream().filter(include::equals).mapToLong(Person::getAge).sum();
|
||||
long i = collection.stream().filter(include::equals).mapToLong(Person::getAge).sum();
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class Main {
|
||||
}
|
||||
|
||||
public double test(List<Person> collection) {
|
||||
double d = collection.stream().filter(person -> !(person.getAge() == 10)).mapToDouble(Person::getAge).sum();
|
||||
double d = collection.stream().filter(person -> !(person.getAge() == 10)).mapToDouble(Person::getAge).sum();
|
||||
return d;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
||||
public class Main {
|
||||
|
||||
public List<String> test(Map<String, List<String>> map) {
|
||||
List<String> result = map.entrySet().stream().filter(entry -> !entry.getKey().isEmpty()).map(Map.Entry::getValue).filter(Objects::nonNull).flatMap(Collection::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
|
||||
List<String> result = map.entrySet().stream().filter(entry -> !entry.getKey().isEmpty()).map(Map.Entry::getValue).filter(Objects::nonNull).flatMap(Collection::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
||||
public class Main {
|
||||
|
||||
public List<String> test(Map<String, List<String>> map) {
|
||||
List<String> result = map.entrySet().stream().filter(entry -> !entry.getKey().isEmpty()).map(Map.Entry::getValue).filter(Objects::nonNull).flatMap(Collection::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
|
||||
List<String> result = map.entrySet().stream().filter(entry -> !entry.getKey().isEmpty()).map(Map.Entry::getValue).filter(Objects::nonNull).flatMap(Collection::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class Main {
|
||||
}
|
||||
|
||||
public long test(List<Person> collection) {
|
||||
long i = collection.stream().filter(person -> person != null && person.getAge() >= 10).mapToLong(Person::getAge).sum();
|
||||
long i = collection.stream().filter(person -> person != null && person.getAge() >= 10).mapToLong(Person::getAge).sum();
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ 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).count();
|
||||
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).count();
|
||||
return longStrings;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.Set;
|
||||
|
||||
public class Main {
|
||||
public void test(List<Set<String>> nested) {
|
||||
int count = (int) nested.stream().filter(Objects::nonNull).flatMap(Collection::stream).filter(str -> str.startsWith("xyz")).count();
|
||||
int count = (int) nested.stream().filter(Objects::nonNull).flatMap(Collection::stream).filter(str -> str.startsWith("xyz")).count();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public int testPrimitiveArray(int[] data) {
|
||||
int count = (int) Arrays.stream(data).mapToLong(val -> val * val).filter(square -> square > 100).count();
|
||||
int count = (int) Arrays.stream(data).mapToLong(val -> val * val).filter(square -> square > 100).count();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public void test(List<String[]> list) {
|
||||
List<String> result = list.stream().filter(arr -> arr.length > 2).flatMap(Arrays::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
|
||||
List<String> result = list.stream().filter(arr -> arr.length > 2).flatMap(Arrays::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,6 +7,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public void test(Map<String, String[]> map) {
|
||||
List<String> result = map.entrySet().stream().filter(entry -> entry.getKey().startsWith("x")).map(Map.Entry::getValue).flatMap(Arrays::stream).map(String::trim).collect(Collectors.toList());
|
||||
List<String> result = map.entrySet().stream().filter(entry -> entry.getKey().startsWith("x")).map(Map.Entry::getValue).flatMap(Arrays::stream).map(String::trim).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,6 +7,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public void test(Map<String, String[]> map) {
|
||||
List<String> result = map.entrySet().stream().filter(entry -> entry.getKey().startsWith("x")).map(Map.Entry::getValue).flatMap(Arrays::stream).map(String::trim).collect(Collectors.toList());
|
||||
List<String> result = map.entrySet().stream().filter(entry -> entry.getKey().startsWith("x")).map(Map.Entry::getValue).flatMap(Arrays::stream).map(String::trim).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
public int[] testMap(Map<String, List<String>> map) throws Exception {
|
||||
int[] arr = map.values().stream().filter(Objects::nonNull).findFirst().map(list -> new int[]{list.size()}).orElse(null);
|
||||
int[] arr = map.values().stream().filter(Objects::nonNull).findFirst().map(list -> new int[]{list.size()}).orElse(null);
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
public void testMap(Map<String, List<String>> map) throws Exception {
|
||||
int firstSize = map.values().stream().filter(Objects::nonNull).findFirst().map(List::size).orElse(0);
|
||||
int firstSize = map.values().stream().filter(Objects::nonNull).findFirst().map(List::size).orElse(0);
|
||||
// comment
|
||||
System.out.println(firstSize);
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public void testCast(List<Object> data) {
|
||||
String found = (String) data.stream().filter(obj -> obj instanceof String).findFirst().orElse(null);
|
||||
String found = (String) data.stream().filter(obj -> obj instanceof String).findFirst().orElse(null);
|
||||
System.out.println(found);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.Map;
|
||||
|
||||
public class Main {
|
||||
public void testMap(Map<String, List<String>> map) throws Exception {
|
||||
int bigSize = map.values().stream().mapToInt(List::size).filter(size -> size > 10).findFirst().orElse(0);
|
||||
int bigSize = map.values().stream().mapToInt(List::size).filter(size -> size > 10).findFirst().orElse(0);
|
||||
System.out.println(bigSize);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
public void testMap(Map<String, List<String>> map) throws Exception {
|
||||
String firstStr = map.values().stream().filter(Objects::nonNull).flatMap(Collection::stream).filter(str -> !str.isEmpty()).findFirst().orElse("");
|
||||
String firstStr = map.values().stream().filter(Objects::nonNull).flatMap(Collection::stream).filter(str -> !str.isEmpty()).findFirst().orElse("");
|
||||
System.out.println(firstStr);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.Optional;
|
||||
|
||||
public class Main {
|
||||
private static String test(List<String> list) {
|
||||
Optional<String> found = list.stream().filter(Objects::nonNull).findFirst();
|
||||
Optional<String> found = list.stream().filter(Objects::nonNull).findFirst();
|
||||
// optional!
|
||||
return found.orElse(null);
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ public class Main {
|
||||
}
|
||||
|
||||
public Optional<String> test(List<Object> objects) {
|
||||
Optional<String> result = objects.stream().filter(obj -> obj instanceof String).findFirst().flatMap(obj -> trim((String) obj));
|
||||
Optional<String> result = objects.stream().filter(obj -> obj instanceof String).findFirst().flatMap(obj -> trim((String) obj));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public class Test {
|
||||
public void test() {
|
||||
long count = IntStream.range(0, 10).mapToObj(i -> LongStream.range(0, i)).flatMapToLong(Function.identity()).mapToObj(l -> Stream.of("x", "y", "z")).flatMap(Function.identity()).flatMapToInt(s -> IntStream.range(0, s.length())).count();
|
||||
long count = IntStream.range(0, 10).mapToObj(i -> LongStream.range(0, i)).flatMapToLong(Function.identity()).mapToObj(l -> Stream.of("x", "y", "z")).flatMap(Function.identity()).flatMapToInt(s -> IntStream.range(0, s.length())).count();
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<String> test(String[][] arr) {
|
||||
List<String> result = Arrays.stream(arr).filter(Objects::nonNull).flatMap(Arrays::stream).collect(Collectors.toList());
|
||||
List<String> result = Arrays.stream(arr).filter(Objects::nonNull).flatMap(Arrays::stream).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<Integer> test(int[][] arr) {
|
||||
List<Integer> result = Arrays.stream(arr).filter(Objects::nonNull).flatMapToInt(Arrays::stream).boxed().collect(Collectors.toList());
|
||||
List<Integer> result = Arrays.stream(arr).filter(Objects::nonNull).flatMapToInt(Arrays::stream).boxed().collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -5,12 +5,12 @@ import java.util.stream.Collectors;
|
||||
// Java 8 language level used: no toUnmodifiable suggestions
|
||||
class Test {
|
||||
List<String> test(String[] list) {
|
||||
List<String> result = Arrays.stream(list).filter(s -> !s.isEmpty()).collect(Collectors.toCollection(LinkedList::new));
|
||||
List<String> result = Arrays.stream(list).filter(s -> !s.isEmpty()).collect(Collectors.toCollection(LinkedList::new));
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
Collection<String> test2(String[] list) {
|
||||
Set<String> result = Arrays.stream(list).filter(s -> !s.isEmpty()).collect(Collectors.toSet());
|
||||
Set<String> result = Arrays.stream(list).filter(s -> !s.isEmpty()).collect(Collectors.toSet());
|
||||
return Collections.unmodifiableCollection(result);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Test {
|
||||
}
|
||||
|
||||
Set<String> test4(String[] array) {
|
||||
Set<String> result = Arrays.stream(array).filter(s -> !s.isEmpty()).collect(Collectors.toCollection(TreeSet::new));
|
||||
Set<String> result = Arrays.stream(array).filter(s -> !s.isEmpty()).collect(Collectors.toCollection(TreeSet::new));
|
||||
return Collections.unmodifiableSet(result);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -16,7 +16,7 @@ class Test {
|
||||
}
|
||||
|
||||
Set<String> test4(String[] array) {
|
||||
Set<String> result = Arrays.stream(array).filter(s -> !s.isEmpty()).collect(Collectors.toCollection(TreeSet::new));
|
||||
Set<String> result = Arrays.stream(array).filter(s -> !s.isEmpty()).collect(Collectors.toCollection(TreeSet::new));
|
||||
// toUnmodifiableSet will not preserve order; not suggested here
|
||||
return Collections.unmodifiableSet(result);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class Test {
|
||||
}
|
||||
|
||||
Map<String, Integer> map1(List<String> input) {
|
||||
Map<String, Integer> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(s -> s, String::length, (a, b) -> b, TreeMap::new));
|
||||
Map<String, Integer> result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(s -> s, String::length, (a, b) -> b, TreeMap::new));
|
||||
return Collections.unmodifiableMap(result);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public static void test(List<String> data) {
|
||||
List<String> result = data.stream().takeWhile(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||
List<String> result = data.stream().takeWhile(s -> !s.isEmpty()).collect(Collectors.toList());
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
private static String work2(List<String> strs) {
|
||||
String sb = strs.stream().collect(Collectors.joining(",", "{", "}"));
|
||||
String sb = strs.stream().collect(Collectors.joining(",", "{", "}"));
|
||||
// before
|
||||
// after
|
||||
// inside
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining());
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining());
|
||||
String s = sb;
|
||||
return s.trim();
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ public class Test {
|
||||
int BUFLENGTH = 42;
|
||||
char CH = 'a';
|
||||
|
||||
String sb = IntStream.range(0, BUFLENGTH >> 1).mapToObj(i -> "\u041b" + CH + 'i').collect(Collectors.joining());
|
||||
String sb = IntStream.range(0, BUFLENGTH >> 1).mapToObj(i -> "\u041b" + CH + 'i').collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).map(s -> String.valueOf(s.length())).collect(Collectors.joining("\""));
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).map(s -> String.valueOf(s.length())).collect(Collectors.joining("\""));
|
||||
return sb.trim();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
private static String work2(List<String> strs) {
|
||||
String sb = strs.stream().collect(Collectors.joining(",", "{", "}"));
|
||||
String sb = strs.stream().collect(Collectors.joining(",", "{", "}"));
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
final String sb = list.stream().filter(s -> !s.isEmpty()).map(String::trim).collect(Collectors.joining("", "ctor" + "first", ""));
|
||||
final String sb = list.stream().filter(s -> !s.isEmpty()).map(String::trim).collect(Collectors.joining("", "ctor" + "first", ""));
|
||||
return sb.length() == 0 ? null : sb;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining(",", "[", "]"));
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining(",", "[", "]"));
|
||||
return sb.trim();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(",", "prefix", ""));
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(",", "prefix", ""));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
public static int find(List<List<String>> list) {
|
||||
String sb = IntStream.iterate(0, i -> i + 1).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
String sb = IntStream.iterate(0, i -> i + 1).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
public static int find(List<List<String>> list) {
|
||||
String sb = IntStream.iterate(0, i -> i + 23 * 11).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
String sb = IntStream.iterate(0, i -> i + 23 * 11).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
public static int find(List<List<String>> list) {
|
||||
String sb = IntStream.iterate(0, i -> i * (i + 23)).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
String sb = IntStream.iterate(0, i -> i * (i + 23)).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,6 +6,6 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
public static int find(List<List<String>> list) {
|
||||
String sb = IntStream.iterate(0, i -> (int) (i + 10L)).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
String sb = IntStream.iterate(0, i -> (int) (i + 10L)).filter(i -> i % 100 == 0).mapToObj(String::valueOf).collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,6 +14,6 @@ class B extends A {}
|
||||
|
||||
public class Main {
|
||||
public static int find(List<List<String>> list) {
|
||||
String sb = Stream.iterate(new A(), A::next).filter(a -> a.x % 100 == 0).map(a -> String.valueOf(a.x)).collect(Collectors.joining());
|
||||
String sb = Stream.iterate(new A(), A::next).filter(a -> a.x % 100 == 0).map(a -> String.valueOf(a.x)).collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining("", "initial", ""));
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining("", "initial", ""));
|
||||
return sb.trim();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,6 +7,6 @@ import java.util.stream.IntStream;
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
int BUFLENGTH = 42;
|
||||
String sb = IntStream.range(0, BUFLENGTH >> 1).mapToObj(i -> true ? "a" : "b").collect(Collectors.joining());
|
||||
String sb = IntStream.range(0, BUFLENGTH >> 1).mapToObj(i -> true ? "a" : "b").collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user