Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Last active July 20, 2023 06:55
Show Gist options
  • Save bastienapp/d31a5a3d61656264ba2ddc93c7c0ac2e to your computer and use it in GitHub Desktop.
Save bastienapp/d31a5a3d61656264ba2ddc93c7c0ac2e to your computer and use it in GitHub Desktop.
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