@@ -24,72 +24,72 @@ public final class CollectUtil {
2424 private CollectUtil () {
2525 }
2626
27- public static <T , R > Set <R > collectToSet (Collection <T > items , Function < T , @ Nullable R > mapper ) {
27+ public static <T , R > Set <R > collectToSet (Collection <T > items , NullableFunction <? super T , R > mapper ) {
2828 return items .stream ()
29- .map (mapper )
29+ .map (mapper :: apply )
3030 .filter (Objects ::nonNull )
3131 .collect (Collectors .toUnmodifiableSet ());
3232 }
3333
34- public static <T , R > Set <R > collectToSet (Streamable <T > items , Function < T , @ Nullable R > mapper ) {
34+ public static <T , R > Set <R > collectToSet (Streamable <T > items , NullableFunction <? super T , R > mapper ) {
3535 return items .stream ()
36- .map (mapper )
36+ .map (mapper :: apply )
3737 .filter (Objects ::nonNull )
3838 .collect (Collectors .toUnmodifiableSet ());
3939 }
4040
41- public static <T , R > Set <R > collectToSet (Stream <T > items , Function < T , @ Nullable R > mapper ) {
41+ public static <T , R > Set <R > collectToSet (Stream <T > items , NullableFunction <? super T , R > mapper ) {
4242 return items
43- .map (mapper )
43+ .map (mapper :: apply )
4444 .filter (Objects ::nonNull )
4545 .collect (Collectors .toUnmodifiableSet ());
4646 }
4747
4848 @ SuppressWarnings ("java:S6204" )
49- public static <T , R > List <R > collectToList (Collection <T > items , Function < T , @ Nullable R > mapper ) {
49+ public static <T , R > List <R > collectToList (Collection <T > items , NullableFunction <? super T , R > mapper ) {
5050 //noinspection SimplifyStreamApiCallChains
5151 return items .stream ()
52- .map (mapper )
52+ .map (mapper :: apply )
5353 .filter (Objects ::nonNull )
5454 .collect (Collectors .toUnmodifiableList ());
5555 }
5656
5757 @ SuppressWarnings ("java:S6204" )
58- public static <T , R > List <R > collectToList (Streamable <T > items , Function < T , @ Nullable R > mapper ) {
58+ public static <T , R > List <R > collectToList (Streamable <T > items , NullableFunction <? super T , R > mapper ) {
5959 //noinspection SimplifyStreamApiCallChains
6060 return items .stream ()
61- .map (mapper )
61+ .map (mapper :: apply )
6262 .filter (Objects ::nonNull )
6363 .collect (Collectors .toUnmodifiableList ());
6464 }
6565
6666 @ SuppressWarnings ("java:S6204" )
67- public static <T , R > List <R > collectToList (Stream <T > items , Function < T , @ Nullable R > mapper ) {
67+ public static <T , R > List <R > collectToList (Stream <T > items , NullableFunction <? super T , R > mapper ) {
6868 //noinspection SimplifyStreamApiCallChains
6969 return items
70- .map (mapper )
70+ .map (mapper :: apply )
7171 .filter (Objects ::nonNull )
7272 .collect (Collectors .toUnmodifiableList ());
7373 }
7474
75- public static <T , R > Stream <R > collectToStream (Collection <T > items , Function < T , @ Nullable R > mapper ) {
75+ public static <T , R > Stream <R > collectToStream (Collection <T > items , NullableFunction <? super T , R > mapper ) {
7676 //noinspection NullableProblems
7777 return items .stream ()
78- .map (mapper )
78+ .map (mapper :: apply )
7979 .filter (Objects ::nonNull );
8080 }
8181
82- public static <T , R > Stream <R > collectToStream (Streamable <T > items , Function < T , @ Nullable R > mapper ) {
82+ public static <T , R > Stream <R > collectToStream (Streamable <T > items , NullableFunction <? super T , R > mapper ) {
8383 //noinspection NullableProblems
8484 return items .stream ()
85- .map (mapper )
85+ .map (mapper :: apply )
8686 .filter (Objects ::nonNull );
8787 }
8888
89- public static <T , R > Stream <R > collectToStream (Stream <T > items , Function < T , @ Nullable R > mapper ) {
89+ public static <T , R > Stream <R > collectToStream (Stream <T > items , NullableFunction <? super T , R > mapper ) {
9090 //noinspection NullableProblems
9191 return items
92- .map (mapper )
92+ .map (mapper :: apply )
9393 .filter (Objects ::nonNull );
9494 }
9595
0 commit comments