Skip to content

Commit 9d14a94

Browse files
committed
add getItems it IPlaylist
1 parent fcf3d08 commit 9d14a94

5 files changed

Lines changed: 30 additions & 3 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package se.michaelthelin.spotify.model_objects.interfaces;
2+
3+
/**
4+
* Represents an object that has a total count.
5+
*
6+
* <p>This interface is implemented by objects that provide a total count of items,
7+
* such as paging objects, followers, and playlist item information.
8+
*/
9+
public interface IHasTotal {
10+
/**
11+
* Get the total count.
12+
*
13+
* @return The total count, or {@code null} if not available.
14+
*/
15+
Integer getTotal();
16+
}
17+

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ public interface IPlaylist {
8888
*/
8989
Boolean getIsPublicAccess();
9090

91+
/**
92+
* Get information about the items in the playlist. The concrete type depends on the specific playlist object type.
93+
*
94+
* @return Item information containing total count.
95+
*/
96+
IHasTotal getItems();
97+
9198
/**
9299
* Get the snapshot ID, the version identifier for the current playlist. Can be supplied in other requests to target
93100
* a specific playlist version.

‎src/main/java/se/michaelthelin/spotify/model_objects/miscellaneous/PlaylistTracksInformation.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
44
import com.google.gson.JsonObject;
55
import se.michaelthelin.spotify.model_objects.AbstractModelObject;
6+
import se.michaelthelin.spotify.model_objects.interfaces.IHasTotal;
67

78
/**
89
* Retrieve information about Playlist Track Information objects by building instances from this class.
910
*/
1011
@JsonDeserialize(builder = PlaylistTracksInformation.Builder.class)
11-
public class PlaylistTracksInformation extends AbstractModelObject {
12+
public class PlaylistTracksInformation extends AbstractModelObject implements IHasTotal {
1213
/** A link to the Web API endpoint where full details of the playlist's tracks can be retrieved. */
1314
private final String href;
1415
/** Number of tracks in the playlist. */

‎src/main/java/se/michaelthelin/spotify/model_objects/specification/Paging.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
44
import com.google.gson.JsonObject;
55
import se.michaelthelin.spotify.model_objects.AbstractModelObject;
6+
import se.michaelthelin.spotify.model_objects.interfaces.IHasTotal;
67

78
import java.lang.reflect.ParameterizedType;
89
import java.util.Arrays;
@@ -16,7 +17,7 @@
1617
* @param <T> The type of the objects contained in a paging object.
1718
*/
1819
@JsonDeserialize(builder = Paging.Builder.class)
19-
public class Paging<T> extends AbstractModelObject {
20+
public class Paging<T> extends AbstractModelObject implements IHasTotal {
2021
/** The Spotify Web API endpoint URL. */
2122
private final String href;
2223
/** Array of items in the paging object. */

‎src/main/java/se/michaelthelin/spotify/model_objects/specification/PagingCursorbased.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
44
import com.google.gson.JsonObject;
55
import se.michaelthelin.spotify.model_objects.AbstractModelObject;
6+
import se.michaelthelin.spotify.model_objects.interfaces.IHasTotal;
67

78
import java.lang.reflect.ParameterizedType;
89
import java.util.Arrays;
@@ -16,7 +17,7 @@
1617
* @param <T> The type of the objects contained in a paging object.
1718
*/
1819
@JsonDeserialize(builder = PagingCursorbased.Builder.class)
19-
public class PagingCursorbased<T> extends AbstractModelObject {
20+
public class PagingCursorbased<T> extends AbstractModelObject implements IHasTotal {
2021
/** The Spotify Web API endpoint URL. */
2122
private final String href;
2223
/** Array of items in the paging object. */

0 commit comments

Comments
 (0)