1 | package org.cardanofoundation.explorer.api.util; | |
2 | ||
3 | import java.util.Collection; | |
4 | import java.util.List; | |
5 | import java.util.Map; | |
6 | import java.util.Set; | |
7 | import java.util.function.Consumer; | |
8 | import java.util.function.Function; | |
9 | import java.util.function.Predicate; | |
10 | import java.util.stream.Collectors; | |
11 | ||
12 | import lombok.experimental.UtilityClass; | |
13 | ||
14 | @UtilityClass | |
15 | public class StreamUtil { | |
16 | ||
17 | public static <T, R> List<R> mapApply(Collection<T> collection, Function<T, R> function) { | |
18 |
1
1. mapApply : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/util/StreamUtil::mapApply → NO_COVERAGE |
return collection.stream().map(function).collect(Collectors.toList()); |
19 | } | |
20 | ||
21 | public static <T, R> Set<R> mapApplySet(Collection<T> collection, Function<T, R> function) { | |
22 |
1
1. mapApplySet : replaced return value with Collections.emptySet for org/cardanofoundation/explorer/api/util/StreamUtil::mapApplySet → NO_COVERAGE |
return collection.stream().map(function).collect(Collectors.toSet()); |
23 | } | |
24 | ||
25 | public static <T> List<T> filterApply(Collection<T> collection, Predicate<T> filter) { | |
26 |
1
1. filterApply : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/util/StreamUtil::filterApply → NO_COVERAGE |
return collection.stream().filter(filter).collect(Collectors.toList()); |
27 | } | |
28 | ||
29 | public static <T, R> List<R> mapThenFilterApply( | |
30 | Collection<T> collection, Function<T, R> function, Predicate<R> predicate) { | |
31 |
1
1. mapThenFilterApply : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/util/StreamUtil::mapThenFilterApply → NO_COVERAGE |
return collection.stream().map(function).filter(predicate).collect(Collectors.toList()); |
32 | } | |
33 | ||
34 | public static <T, R> List<R> filterThenMapApply( | |
35 | Collection<T> collection, Predicate<T> predicate, Function<T, R> function) { | |
36 |
1
1. filterThenMapApply : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/util/StreamUtil::filterThenMapApply → NO_COVERAGE |
return collection.stream().filter(predicate).map(function).collect(Collectors.toList()); |
37 | } | |
38 | ||
39 | public static <T, R> Set<R> mapThenFilterApplyToSet( | |
40 | Collection<T> collection, Function<T, R> function, Predicate<R> predicate) { | |
41 |
1
1. mapThenFilterApplyToSet : replaced return value with Collections.emptySet for org/cardanofoundation/explorer/api/util/StreamUtil::mapThenFilterApplyToSet → NO_COVERAGE |
return collection.stream().map(function).filter(predicate).collect(Collectors.toSet()); |
42 | } | |
43 | ||
44 | public static <V, K> Map<K, V> toMap(Collection<V> collection, Function<V, K> function) { | |
45 |
1
1. toMap : replaced return value with Collections.emptyMap for org/cardanofoundation/explorer/api/util/StreamUtil::toMap → NO_COVERAGE |
return collection.stream().collect(Collectors.toMap(function, Function.identity())); |
46 | } | |
47 | ||
48 | public static <V, K, P> Map<K, P> toMap( | |
49 | Collection<V> collection, Function<V, K> functionKey, Function<V, P> functionVal) { | |
50 |
1
1. toMap : replaced return value with Collections.emptyMap for org/cardanofoundation/explorer/api/util/StreamUtil::toMap → KILLED |
return collection.stream().collect(Collectors.toMap(functionKey, functionVal)); |
51 | } | |
52 | ||
53 | public static <V, K, P> Map<K, P> filterApplyThenToMap( | |
54 | Collection<V> collection, | |
55 | Predicate<V> predicate, | |
56 | Function<V, K> functionKey, | |
57 | Function<V, P> functionVal) { | |
58 |
1
1. filterApplyThenToMap : replaced return value with Collections.emptyMap for org/cardanofoundation/explorer/api/util/StreamUtil::filterApplyThenToMap → NO_COVERAGE |
return collection.stream() |
59 | .filter(predicate) | |
60 | .collect(Collectors.toMap(functionKey, functionVal)); | |
61 | } | |
62 | ||
63 | public static <T, K> Map<K, List<T>> groupingApply( | |
64 | Collection<T> collection, Function<T, K> function) { | |
65 |
1
1. groupingApply : replaced return value with Collections.emptyMap for org/cardanofoundation/explorer/api/util/StreamUtil::groupingApply → NO_COVERAGE |
return collection.stream().collect(Collectors.groupingBy(function)); |
66 | } | |
67 | ||
68 | public static <T, K, V> Map<K, List<V>> groupingApply( | |
69 | Collection<T> collection, Function<T, K> functionKey, Function<T, V> functionValue) { | |
70 |
1
1. groupingApply : replaced return value with Collections.emptyMap for org/cardanofoundation/explorer/api/util/StreamUtil::groupingApply → NO_COVERAGE |
return collection.stream() |
71 | .collect( | |
72 | Collectors.groupingBy( | |
73 | functionKey, Collectors.mapping(functionValue, Collectors.toList()))); | |
74 | } | |
75 | ||
76 | public static <T, R> Function<T, R> of(Function<T, R> function) { | |
77 |
1
1. of : replaced return value with null for org/cardanofoundation/explorer/api/util/StreamUtil::of → NO_COVERAGE |
return function; |
78 | } | |
79 | ||
80 | public static <T> Function<T, T> peek(Consumer<? super T> consumer) { | |
81 |
1
1. peek : replaced return value with null for org/cardanofoundation/explorer/api/util/StreamUtil::peek → NO_COVERAGE |
return t -> { |
82 |
1
1. lambda$peek$0 : removed call to java/util/function/Consumer::accept → NO_COVERAGE |
consumer.accept(t); |
83 |
1
1. lambda$peek$0 : replaced return value with null for org/cardanofoundation/explorer/api/util/StreamUtil::lambda$peek$0 → NO_COVERAGE |
return t; |
84 | }; | |
85 | } | |
86 | } | |
Mutations | ||
18 |
1.1 |
|
22 |
1.1 |
|
26 |
1.1 |
|
31 |
1.1 |
|
36 |
1.1 |
|
41 |
1.1 |
|
45 |
1.1 |
|
50 |
1.1 |
|
58 |
1.1 |
|
65 |
1.1 |
|
70 |
1.1 |
|
77 |
1.1 |
|
81 |
1.1 |
|
82 |
1.1 |
|
83 |
1.1 |