Skip to content

Commit dfd69bd

Browse files
committed
refactor: use more concise APIs to collect streams
1 parent 53486b7 commit dfd69bd

File tree

8 files changed

+11
-20
lines changed

8 files changed

+11
-20
lines changed

articles/flow/component-internals/visibility.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ container.add(label);
5252
5353
// prints 1 - the server-side structure is preserved
5454
// regardless of whether the component is visible or not
55-
System.out.println("Number of children: "
56-
+ container.getChildren().collect(
57-
Collectors.counting()));
55+
System.out.println("Number of children: " + container.getChildCount());
5856
----
5957
====
6058

articles/flow/routing/registered-routes.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To retrieve all the routes defined by parent layout, use:
2727
List<RouteData> routes = RouteConfiguration.forSessionScope().getAvailableRoutes();
2828
List<RouteData> myRoutes = routes.stream()
2929
.filter(routeData -> MyParentLayout.class.equals((routeData.getParentLayout())))
30-
.collect(Collectors.toList());
30+
.toList();
3131
----
3232

3333

src/main/java/com/vaadin/demo/component/datepicker/DatePickerIndividualInputFields.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public DatePickerIndividualInputFields() {
2929
LocalDate now = LocalDate.now(ZoneId.systemDefault());
3030

3131
List<Integer> selectableYears = IntStream
32-
.range(now.getYear() - 99, now.getYear() + 1).boxed()
33-
.collect(Collectors.toList());
32+
.range(now.getYear() - 99, now.getYear() + 1).boxed().toList();
3433

3534
yearPicker = new ComboBox<>("Year", selectableYears);
3635
yearPicker.setWidth(6, Unit.EM);
@@ -80,8 +79,8 @@ private void updateDayPicker() {
8079
monthPicker.getValue(), 1);
8180
int lengthOfMonth = startOfMonth.lengthOfMonth();
8281

83-
dayPicker.setItems(IntStream.range(1, lengthOfMonth + 1).boxed()
84-
.collect(Collectors.toList()));
82+
dayPicker.setItems(
83+
IntStream.range(1, lengthOfMonth + 1).boxed().toList());
8584
}
8685
// end::snippet[]
8786

src/main/java/com/vaadin/demo/component/grid/GridDragDropFilters.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ public class GridDragDropFilters extends Div {
2626
public GridDragDropFilters() {
2727

2828
List<Person> people = DataService.getPeople();
29-
managers = people.stream().filter(Person::isManager)
30-
.collect(Collectors.toList());
29+
managers = people.stream().filter(Person::isManager).toList();
3130
staffGroupedByMangers = people.stream()
3231
.filter(person -> person.getManagerId() != null)
33-
.collect(Collectors.groupingBy(Person::getManagerId,
34-
Collectors.toList()));
32+
.collect(Collectors.groupingBy(Person::getManagerId));
3533

3634
// tag::snippet[]
3735
TreeGrid<Person> treeGrid = setupTreeGrid();

src/main/java/com/vaadin/demo/component/grid/GridHeaderFooterStyling.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public GridHeaderFooterStyling() {
3535

3636
private static List<PersonWithRating> createDataSet() {
3737
return DataService.getPeople().stream()
38-
.map(PersonWithRating::generateFromPerson)
39-
.collect(Collectors.toList());
38+
.map(PersonWithRating::generateFromPerson).toList();
4039
}
4140

4241
public static class Exporter // hidden-source-line

src/main/java/com/vaadin/demo/component/grid/GridStyling.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public GridStyling() {
3939

4040
private static List<PersonWithRating> createDataSet() {
4141
return DataService.getPeople().stream()
42-
.map(PersonWithRating::generateFromPerson)
43-
.collect(Collectors.toList());
42+
.map(PersonWithRating::generateFromPerson).toList();
4443
}
4544

4645
public static class Exporter // hidden-source-line

src/main/java/com/vaadin/demo/component/treegrid/TreeGridDragDrop.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public TreeGridDragDrop() {
2929
managers = people.stream().filter(Person::isManager).toList();
3030
staffGroupedByMangers = people.stream()
3131
.filter(person -> person.getManagerId() != null)
32-
.collect(Collectors.groupingBy(Person::getManagerId,
33-
Collectors.toList()));
32+
.collect(Collectors.groupingBy(Person::getManagerId));
3433

3534
// tag::snippet[]
3635
TreeGrid<Person> treeGrid = setupTreeGrid();

src/main/java/com/vaadin/demo/fusion/security/authentication/UserInfoService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public UserInfo getUserInfo() {
2424
.getAuthentication();
2525

2626
final List<String> authorities = auth.getAuthorities().stream()
27-
.map(GrantedAuthority::getAuthority)
28-
.collect(Collectors.toList());
27+
.map(GrantedAuthority::getAuthority).toList();
2928

3029
return new UserInfo(auth.getName(), authorities);
3130
}

0 commit comments

Comments
 (0)