Last active
July 20, 2023 06:55
-
-
Save bastienapp/d31a5a3d61656264ba2ddc93c7c0ac2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.wildmovies.entity; | |
import org.springframework.beans.factory.annotation.Value; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public interface UserProjection { | |
static List<String> getMovieComments(List<Movie> movies) { | |
return movies | |
.stream() | |
.map(movie -> movie | |
.getCommentList() | |
.stream() | |
.map(MovieComment::getContent) | |
.collect(Collectors.toList())) | |
.reduce((result, commentList) -> { | |
result.addAll(commentList); | |
return result; | |
}).orElseThrow(); | |
} | |
String getEmail(); | |
@Value("#{T(com.example.wildmovies.entity.UserProjection).getMovieComments(target.getFavouriteMovies())}") | |
List<String> getComments(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment