map

//postRepository์—์„œ ๋„˜์–ด์˜จ ๊ฒฐ๊ณผ๋ฅผ postsRepository.findAllDesc().stream() //Stream์„ ํ†ตํ•ด map์œผ๋กœ new PostsListResponseDto ์— ๋งคํ•‘ ํ•ด์ค€๋‹ค. //PostsListResponseDto์—์„œ๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ postRepository์—์„œ ๋„˜์–ด์˜จ ๊ฒฐ๊ณผ Entity posts๋ฅผ ๋ฐ›๊ณ  ์žˆ์œผ๋ฏ€๋กœ //๊ฒฐ๊ณผ์ ์œผ๋กœ .map(posts -> new PostsListResponseDto(posts)) .map(PostsListResponseDto::new) //collect๋ฅผ ์‚ฌ์šฉํ•ด์„œ List๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. .collect(Collectors.toList()); stream์ด๋ผ๋Š” ๊ฒŒ ์žˆ๋Š” ๊ฒƒ ์กฐ์ฐจ ๋ชฐ๋ผ์„œ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ํ˜ผ๋ž€์Šค๋Ÿฌ์› ๋‹ค ๋žŒ๋‹ค์‹์„ ๋ฐฐ์šด ์ ์ด ์—†์œผ๋‹ˆ. ใ… ..
์• ์ •์“ฐ
'map' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก