Skip to content

Commit 57276dd

Browse files
committed
fix(playlist): allow to extend the has-total interface
1 parent 2b41d3e commit 57276dd

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/main/java/se/michaelthelin/spotify/model_objects/interfaces/IPlaylist.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
*
1313
* <p>This interface provides a common base for {@link Playlist} and
1414
* {@link PlaylistSimplified} objects.
15+
*
16+
* @param <T> The concrete type of the items/tracks metadata object. {@link Playlist} uses
17+
* {@link se.michaelthelin.spotify.model_objects.specification.Paging} and
18+
* {@link PlaylistSimplified} uses
19+
* {@link se.michaelthelin.spotify.model_objects.miscellaneous.PlaylistTracksInformation}.
1520
*/
16-
public interface IPlaylist {
21+
public interface IPlaylist<T extends IHasTotal> {
1722
/**
1823
* Check whether the owner allows other users to modify the playlist.
1924
*
@@ -93,7 +98,7 @@ public interface IPlaylist {
9398
*
9499
* @return Item information containing total count.
95100
*/
96-
IHasTotal getItems();
101+
T getItems();
97102

98103
/**
99104
* Get the snapshot ID, the version identifier for the current playlist. Can be supplied in other requests to target

src/main/java/se/michaelthelin/spotify/model_objects/specification/Playlist.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Playlist objects</a> by building instances from this class.
1616
*/
1717
@JsonDeserialize(builder = Playlist.Builder.class)
18-
public class Playlist extends AbstractModelObject implements IPlaylist {
18+
public class Playlist extends AbstractModelObject implements IPlaylist<Paging<PlaylistTrack>> {
1919
/** Whether the playlist is collaborative. */
2020
private final Boolean collaborative;
2121
/** The description of the playlist. */

src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistSimplified.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* simplified Playlist objects</a> by building instances from this class.
1818
*/
1919
@JsonDeserialize(builder = PlaylistSimplified.Builder.class)
20-
public class PlaylistSimplified extends AbstractModelObject implements ISearchModelObject, IPlaylist {
20+
public class PlaylistSimplified extends AbstractModelObject implements ISearchModelObject, IPlaylist<PlaylistTracksInformation> {
2121
/** Whether the playlist is collaborative. */
2222
private final Boolean collaborative;
2323
/** The description of the playlist. */

0 commit comments

Comments
 (0)