Skip to content

Commit f402834

Browse files
committed
Cleanup: use collectors .toList()
1 parent df5cda3 commit f402834

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/main/java/by/andd3dfx/refactoring/refactored/EventParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public String parse(Event event) {
4343
public List<String> parse(List<Event> events) {
4444
return events.stream()
4545
.map(this::parse)
46-
.collect(Collectors.toList());
46+
.toList();
4747
}
4848
}

src/main/java/by/andd3dfx/tree/equivalent/EquivalentTrees.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public List<Node> findEquivalentSubtrees(Node root) {
6262
entry -> entry.getValue().stream()
6363
.sorted((o1, o2) -> node2Size.get(o2) - node2Size.get(o1))
6464
.limit(2)
65-
.collect(Collectors.toList())
65+
.toList()
6666
));
6767
// Only absent sets with at least 2 related nodes remain
6868

src/test/java/by/andd3dfx/recursion/HanoiTowersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void checkIsFinished(HanoiTowers ht) {
3636
assertTrue("Left column should be empty", ht.getLeft().getStack().isEmpty());
3737
assertTrue("Middle column should be empty", ht.getMiddle().getStack().isEmpty());
3838

39-
List<Integer> disks = ht.getRight().getStack().stream().collect(Collectors.toList());
39+
List<Integer> disks = ht.getRight().getStack().stream().toList();
4040
for (int i = 1; i < disks.size(); i++) {
4141
assertThat("Disk " + (i - 1) + " should be less than disk " + i,
4242
disks.get(i - 1),

src/test/java/by/andd3dfx/tree/BinaryTreeWalkingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void backwardVerticalWalk() {
5555
}
5656

5757
private void checkResultList(List<BinaryTreeWalking.Node<Integer>> result, int[] expectation) {
58-
List<Integer> values = result.stream().map(node -> node.getValue()).collect(Collectors.toList());
58+
List<Integer> values = result.stream().map(BinaryTreeWalking.Node::getValue).toList();
5959
assertThat(values.size(), is(expectation.length));
6060
assertThat(values.toArray(), is(expectation));
6161
}

0 commit comments

Comments
 (0)