Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set<Song> findSongsBySinger(Singer singer) {
- Set<Song> set = new HashSet<>();
- for (Song song : catalog.getSongs()) {
- if (song.getSinger().equals(singer)) {
- set.add(song);
- }
- }
- return set;
- }
- Set<Song> findSongsByAlbum(Album album) {
- Set<Song> set = new HashSet<>();
- for (Song song : catalog.getSongs()) {
- if (song.getAlbum().equals(album)) {
- set.add(song);
- }
- }
- return set;
- }
- Set<Song> findSongsByCollection(SongsCollection collection) {
- return collection.getSongs();
- }
- Set<Song> findSongsByGenre(Genre genre) {
- Set<Song> set= new HashSet<>();
- for (Song song : catalog.getSongs()) {
- if (song.getGenre().equals(genre) || song.getGenre().getParent() != null && song.getGenre().getParent().equals(genre)) {
- set.add(song);
- }
- }
- return set;
- }
- Set<Song> findSongsEqualsYear(int year) {
- Set<Song> set = new HashSet<>();
- for (Song song : catalog.getSongs()) {
- if (song.getYear() == year) {
- set.add(song);
- }
- }
- return set;
- }
- Set<Singer> findSingersBySongCollection(SongsCollection collection) {
- Set<Singer> set = new HashSet<>();
- for (Song song : collection.getSongs()) {
- set.add(song.getSinger());
- }
- return set;
- }
- Set<Album> findAlbumsByGenre(Genre genre) {
- Set<Album> set = new HashSet<>();
- for (Song song : catalog.getSongs()) {
- if (song.getGenre().equals(genre) || song.getGenre().getParent() != null && song.getGenre().getParent().equals(genre)) {
- set.add(song.getAlbum());
- }
- }
- return set;
- }
- Set<SongsCollection> findSongsCollectionBySongs(Set<Song> songsSet) {
- Set<SongsCollection> songsCollectionsSet = new HashSet<>();
- for (SongsCollection songsCollection : catalog.getSongsCollections()) {
- for (Song song : songsCollection.getSongs()) {
- if (songsSet.contains(song)) {
- songsCollectionsSet.add(songsCollection);
- }
- }
- }
- return songsCollectionsSet;
- }
- Set<Genre> findGenresBySongsCollection(SongsCollection collection) {
- Set<Genre> set = new HashSet<>();
- for (Song song : collection.getSongs()) {
- set.add(song.getGenre());
- }
- return set;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement