Created
August 1, 2020 13:44
-
-
Save marceloazvedo/5cc0b5c0ffb184dbb9fa1f9caba1aa16 to your computer and use it in GitHub Desktop.
Your Accumulator
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
public static BiFunction<ArrayList<GenreMovies>, Movie, ArrayList<GenreMovies>> selectAndSeparate(String... genres) { | |
return (findeds, movie) -> { | |
for(String genre : genres) { | |
GenreMovies genreMovieToAdd = getGenreMoviesInListByGenre(genre, findeds); | |
if(genreMovieToAdd == null) { | |
genreMovieToAdd = new GenreMovies(genre); | |
findeds.add(genreMovieToAdd); | |
} | |
if(Arrays.asList(movie.getGenresAsArray()).contains(genre)) { | |
genreMovieToAdd.getMovies().add(movie); | |
} | |
} | |
return findeds; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment