Skip to Content
함수형 프로그래밍 with 자바
book

함수형 프로그래밍 with 자바

by 벤 바이디히, 허귀영
March 2024
Beginner to intermediate
528 pages
10h 48m
Korean
Hanbit Media, Inc.
Content preview from 함수형 프로그래밍 with 자바
276
PART 02
함수형 접근 방식
Predicate
<
User
>
loggedInToday
=
Predicate
.
not
(
user
->
user
.
lastLogin
().
isBefore
(
startOfDay
));
//
중간
필터
연산
사용
Map
<
String
,
Set
<
UUID
>>
todaysLoginsByGroupWithFilterOp
=
users
.
stream
()
.
filter
(
loggedInToday
)
.
collect
(
groupingBy
(
User
::
group
,
mapping
(
User
::
id
,
toSet
())));
//
컬렉터
필터
사용
Map
<
String
,
Set
<
UUID
>>
todaysLoginsByGroupWithFilteringCollector
=
users
.
stream
()
.
collect
(
groupingBy
(
User
::
group
,
filtering
(
loggedInToday
,
mapping
(
User
::
id
,
toSet
()))));
동일한 결과를 예상할 수도 있겠지만 연산의 순서에 따라서 결과는 달라질 수 있습니다.
중간 중간
filterfilter
연산 후 그룹화하기 연산 후 그룹화하기
중간
filter
연산을 통해 수집되기 전에 원치 않는 요소를 제거할 수 있습니다. 따라서 오
늘 로그인하지 않은 사용자의 그룹은 결과
Map
에 포함되지 않게 됩니다. 이 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

실무로 통하는 클린 코드

실무로 통하는 클린 코드

막시밀리아노 콘티에리

Publisher Resources

ISBN: 9791169212175