|
| 1 | +package io.github.yvasyliev.deezer.factory; |
| 2 | + |
| 3 | +import io.github.yvasyliev.deezer.model.Album; |
| 4 | +import io.github.yvasyliev.deezer.model.Artist; |
| 5 | +import io.github.yvasyliev.deezer.model.Playlist; |
| 6 | +import io.github.yvasyliev.deezer.model.Track; |
| 7 | +import io.github.yvasyliev.deezer.model.User; |
| 8 | +import io.github.yvasyliev.deezer.request.DeezerRequest; |
| 9 | +import io.github.yvasyliev.deezer.request.GetByIdDeezerRequest; |
| 10 | +import io.github.yvasyliev.deezer.request.GetByIdPagingDeezerRequest; |
| 11 | +import io.github.yvasyliev.deezer.service.ArtistService; |
| 12 | +import lombok.RequiredArgsConstructor; |
| 13 | + |
| 14 | +/** |
| 15 | + * Factory for creating requests related to artists. |
| 16 | + */ |
| 17 | +@RequiredArgsConstructor |
| 18 | +public class ArtistRequestFactory { |
| 19 | + private final ArtistService artistService; |
| 20 | + |
| 21 | + /** |
| 22 | + * Returns a list of artist's albums. |
| 23 | + * |
| 24 | + * @param artistId artist ID |
| 25 | + * @return list of artist's albums |
| 26 | + */ |
| 27 | + public GetByIdPagingDeezerRequest<Album> getAlbums(long artistId) { |
| 28 | + return new GetByIdPagingDeezerRequest<>(artistId, artistService::getAlbums); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Returns an artist. |
| 33 | + * |
| 34 | + * @param artistId artist ID |
| 35 | + * @return artist |
| 36 | + */ |
| 37 | + public DeezerRequest<Artist> getArtist(long artistId) { |
| 38 | + return new GetByIdDeezerRequest<>(artistId, artistService::getArtist); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Returns a list of artist's fans. |
| 43 | + * |
| 44 | + * @param artistId artist ID |
| 45 | + * @return list of artist's fans |
| 46 | + */ |
| 47 | + public GetByIdPagingDeezerRequest<User> getFans(long artistId) { |
| 48 | + return new GetByIdPagingDeezerRequest<>(artistId, artistService::getFans); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Returns a list of artist's playlists. |
| 53 | + * |
| 54 | + * @param artistId artist ID |
| 55 | + * @return list of artist's playlists |
| 56 | + */ |
| 57 | + public GetByIdPagingDeezerRequest<Playlist> getPlaylists(long artistId) { |
| 58 | + return new GetByIdPagingDeezerRequest<>(artistId, artistService::getPlaylists); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns a list of tracks. |
| 63 | + * |
| 64 | + * @param artistId artist ID |
| 65 | + * @return list of tracks |
| 66 | + */ |
| 67 | + public GetByIdPagingDeezerRequest<Track> getRadio(long artistId) { |
| 68 | + return new GetByIdPagingDeezerRequest<>(artistId, artistService::getRadio); |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Returns a list of related artists. |
| 73 | + * |
| 74 | + * @param artistId artist ID |
| 75 | + * @return list of related artists |
| 76 | + */ |
| 77 | + public GetByIdPagingDeezerRequest<Artist> getRelated(long artistId) { |
| 78 | + return new GetByIdPagingDeezerRequest<>(artistId, artistService::getRelated); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Returns a list of artist's top tracks. |
| 83 | + * |
| 84 | + * @param artistId artist ID |
| 85 | + * @return list of artist's top tracks |
| 86 | + */ |
| 87 | + public GetByIdPagingDeezerRequest<Track> getTop(long artistId) { |
| 88 | + return new GetByIdPagingDeezerRequest<>(artistId, artistService::getTop); |
| 89 | + } |
| 90 | +} |
0 commit comments