update labmda function
This commit is contained in:
parent
672ffdbe9f
commit
4f987c9198
@ -24,13 +24,9 @@ public class ListToMapUnitTest {
|
|||||||
|
|
||||||
Map<Integer, List<String>> convertedMap = new HashMap<>();
|
Map<Integer, List<String>> convertedMap = new HashMap<>();
|
||||||
|
|
||||||
Supplier<List<String>> listSupplier = () -> {
|
Supplier<List<String>> listSupplier = ArrayList::new;
|
||||||
return new ArrayList<>();
|
|
||||||
};
|
|
||||||
|
|
||||||
Supplier<Map<Integer, List<String>>> mapFactory = () -> {
|
Supplier<Map<Integer, List<String>>> mapFactory = HashMap::new;
|
||||||
return new HashMap<>();
|
|
||||||
};
|
|
||||||
convertedMap = strings.stream()
|
convertedMap = strings.stream()
|
||||||
.collect(Collectors.groupingBy(String::length, mapFactory, Collectors.toCollection(listSupplier)));
|
.collect(Collectors.groupingBy(String::length, mapFactory, Collectors.toCollection(listSupplier)));
|
||||||
|
|
||||||
@ -45,13 +41,9 @@ public class ListToMapUnitTest {
|
|||||||
|
|
||||||
Map<Integer, List<String>> convertedMap = new HashMap<>();
|
Map<Integer, List<String>> convertedMap = new HashMap<>();
|
||||||
|
|
||||||
Supplier<Map<Integer, List<String>>> mapFactory = () -> {
|
Supplier<Map<Integer, List<String>>> mapFactory = HashMap::new;
|
||||||
return new HashMap<>();
|
|
||||||
};
|
|
||||||
|
|
||||||
Supplier<List<String>> listSupplier = () -> {
|
Supplier<List<String>> listSupplier = ArrayList::new;
|
||||||
return new ArrayList<>();
|
|
||||||
};
|
|
||||||
|
|
||||||
BiConsumer<Map<Integer, List<String>>, String> accumulator = (response, element) -> {
|
BiConsumer<Map<Integer, List<String>>, String> accumulator = (response, element) -> {
|
||||||
Integer key = element.length();
|
Integer key = element.length();
|
||||||
@ -78,17 +70,11 @@ public class ListToMapUnitTest {
|
|||||||
|
|
||||||
Map<Integer, List<String>> convertedMap = new HashMap<>();
|
Map<Integer, List<String>> convertedMap = new HashMap<>();
|
||||||
|
|
||||||
Supplier<Map<Integer, List<String>>> mapFactory = () -> {
|
Supplier<Map<Integer, List<String>>> mapFactory = HashMap::new;
|
||||||
return new HashMap<>();
|
|
||||||
};
|
|
||||||
|
|
||||||
Supplier<List<String>> listSupplier = () -> {
|
Supplier<List<String>> listSupplier = ArrayList::new;
|
||||||
return new ArrayList<>();
|
|
||||||
};
|
|
||||||
|
|
||||||
Function<String, Integer> keyMapper = (element) -> {
|
Function<String, Integer> keyMapper = String::length;
|
||||||
return element.length();
|
|
||||||
};
|
|
||||||
|
|
||||||
Function<String, List<String>> valueMapper = (element) -> {
|
Function<String, List<String>> valueMapper = (element) -> {
|
||||||
List<String> collection = listSupplier.get();
|
List<String> collection = listSupplier.get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user