-
-
Notifications
You must be signed in to change notification settings - Fork 291
feat: add common interfaces #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dargmuesli
merged 5 commits into
spotify-web-api-java:beta
from
fm-sys:common-interfaces
Apr 29, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
557f20d
add common interfaces
fm-sys fcf3d08
apply copilot review suggestion
fm-sys 01f413e
add getItems to IPlaylist to allow querying number of total tracks
fm-sys 2b41d3e
refactor: sort imports
dargmuesli 57276dd
fix(playlist): allow to extend the has-total interface
dargmuesli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
src/main/java/se/michaelthelin/spotify/model_objects/interfaces/IAlbum.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package se.michaelthelin.spotify.model_objects.interfaces; | ||
|
|
||
| import se.michaelthelin.spotify.enums.AlbumType; | ||
| import se.michaelthelin.spotify.enums.ModelObjectType; | ||
| import se.michaelthelin.spotify.enums.ReleaseDatePrecision; | ||
| import se.michaelthelin.spotify.model_objects.specification.Album; | ||
| import se.michaelthelin.spotify.model_objects.specification.AlbumSimplified; | ||
| import se.michaelthelin.spotify.model_objects.specification.ArtistSimplified; | ||
| import se.michaelthelin.spotify.model_objects.specification.ExternalUrl; | ||
| import se.michaelthelin.spotify.model_objects.specification.Image; | ||
| import se.michaelthelin.spotify.model_objects.special.AlbumSimplifiedSpecial; | ||
|
|
||
| /** | ||
| * Represents the common properties of Spotify Album objects (full and simplified). | ||
| * | ||
| * <p>This interface provides a common base for {@link Album}, {@link AlbumSimplified}, | ||
| * and {@link AlbumSimplifiedSpecial} objects. | ||
| */ | ||
| public interface IAlbum { | ||
| /** | ||
| * Get the type of the album. | ||
| * | ||
| * @return The {@link AlbumType}. | ||
| */ | ||
| AlbumType getAlbumType(); | ||
|
|
||
| /** | ||
| * Get the artists of the album. | ||
| * | ||
| * @return An array of {@link ArtistSimplified} objects. | ||
| */ | ||
| ArtistSimplified[] getArtists(); | ||
|
|
||
| /** | ||
| * Get the external URLs of the album. <br> | ||
| * Example: <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify-URL</a> | ||
| * | ||
| * @return An {@link ExternalUrl} object. | ||
| */ | ||
| ExternalUrl getExternalUrls(); | ||
|
|
||
| /** | ||
| * Get the full Spotify Web API endpoint URL of the album. | ||
| * | ||
| * @return A Spotify Web API endpoint URL. | ||
| */ | ||
| String getHref(); | ||
|
|
||
| /** | ||
| * Get the Spotify ID of the album. | ||
| * | ||
| * @return A <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify album ID</a>. | ||
| */ | ||
| String getId(); | ||
|
|
||
| /** | ||
| * Get the album cover art of the album in different sizes. | ||
| * | ||
| * @return An array of {@link Image} objects. | ||
| */ | ||
| Image[] getImages(); | ||
|
|
||
| /** | ||
| * Get the name of the album. | ||
| * | ||
| * @return Album name. | ||
| */ | ||
| String getName(); | ||
|
|
||
| /** | ||
| * Get the release date of the album with the highest precision available. | ||
| * | ||
| * @return The release date of the album. | ||
| */ | ||
| String getReleaseDate(); | ||
|
|
||
| /** | ||
| * Get the precision of the albums release date. This is needed when the exact release day of an album is not known. | ||
| * | ||
| * @return The precision of the albums release date. | ||
| */ | ||
| ReleaseDatePrecision getReleaseDatePrecision(); | ||
|
|
||
| /** | ||
| * Get the model object type. In this case "album". | ||
| * | ||
| * @return A {@link ModelObjectType}. | ||
| */ | ||
| ModelObjectType getType(); | ||
|
|
||
| /** | ||
| * Get the Spotify URI of the album. | ||
| * | ||
| * @return <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify album URI</a>. | ||
| */ | ||
| String getUri(); | ||
| } | ||
|
|
||
|
|
59 changes: 59 additions & 0 deletions
59
src/main/java/se/michaelthelin/spotify/model_objects/interfaces/IArtist.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package se.michaelthelin.spotify.model_objects.interfaces; | ||
|
|
||
| import se.michaelthelin.spotify.enums.ModelObjectType; | ||
| import se.michaelthelin.spotify.model_objects.specification.Artist; | ||
| import se.michaelthelin.spotify.model_objects.specification.ArtistSimplified; | ||
| import se.michaelthelin.spotify.model_objects.specification.ExternalUrl; | ||
|
|
||
| /** | ||
| * Represents the common properties of Spotify Artist objects (full and simplified). | ||
| * | ||
| * <p>This interface provides a common base for {@link Artist} and | ||
| * {@link ArtistSimplified} objects. | ||
| */ | ||
| public interface IArtist { | ||
| /** | ||
| * Get the external URLs of the artist. <br> | ||
| * Example: <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify-URL</a> | ||
| * | ||
| * @return An {@link ExternalUrl} object. | ||
| */ | ||
| ExternalUrl getExternalUrls(); | ||
|
|
||
| /** | ||
| * Get the full Spotify Web API endpoint URL of the artist. | ||
| * | ||
| * @return A Spotify Web API endpoint URL. | ||
| */ | ||
| String getHref(); | ||
|
|
||
| /** | ||
| * Get the Spotify ID of the artist. | ||
| * | ||
| * @return A <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify artist ID</a>. | ||
| */ | ||
| String getId(); | ||
|
|
||
| /** | ||
| * Get the name of the artist. | ||
| * | ||
| * @return Artist name. | ||
| */ | ||
| String getName(); | ||
|
|
||
| /** | ||
| * Get the model object type. In this case "artist". | ||
| * | ||
| * @return A {@link ModelObjectType}. | ||
| */ | ||
| ModelObjectType getType(); | ||
|
|
||
| /** | ||
| * Get the Spotify URI of the artist. | ||
| * | ||
| * @return <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify artist URI</a>. | ||
| */ | ||
| String getUri(); | ||
| } | ||
|
|
||
|
|
91 changes: 91 additions & 0 deletions
91
src/main/java/se/michaelthelin/spotify/model_objects/interfaces/IEpisode.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| package se.michaelthelin.spotify.model_objects.interfaces; | ||
|
|
||
| import se.michaelthelin.spotify.enums.ReleaseDatePrecision; | ||
| import se.michaelthelin.spotify.model_objects.IPlaylistItem; | ||
| import se.michaelthelin.spotify.model_objects.specification.Episode; | ||
| import se.michaelthelin.spotify.model_objects.specification.EpisodeSimplified; | ||
| import se.michaelthelin.spotify.model_objects.specification.Image; | ||
| import se.michaelthelin.spotify.model_objects.specification.ResumePoint; | ||
|
|
||
| /** | ||
| * Represents the common properties of Spotify Episode objects (full and simplified). | ||
| * | ||
| * <p>This interface extends {@link IPlaylistItem} and provides a common base for | ||
| * {@link Episode} and | ||
| * {@link EpisodeSimplified} | ||
| * objects. | ||
| */ | ||
| public interface IEpisode extends IPlaylistItem { | ||
| /** | ||
| * Get a link to a 30 second preview (MP3 format) of the episode. {@code null} if not available. | ||
| * | ||
| * @return A link to a 30 second preview (MP3 format) of the episode. {@code null} if not available. | ||
| */ | ||
| String getAudioPreviewUrl(); | ||
|
|
||
| /** | ||
| * Get a description of the episode. | ||
| * | ||
| * @return The description of the episode. | ||
| */ | ||
| String getDescription(); | ||
|
|
||
| /** | ||
| * Check whether the episode is explicit or not. | ||
| * | ||
| * @return Whether or not the episode has explicit content ({@code true} = yes it does; {@code false} = no it does not | ||
| * <b>OR</b> unknown). | ||
| */ | ||
| Boolean getExplicit(); | ||
|
|
||
| /** | ||
| * Get the cover art for the episode in various sizes, widest first. | ||
| * | ||
| * @return An array of {@link Image} objects. | ||
| */ | ||
| Image[] getImages(); | ||
|
|
||
| /** | ||
| * Check whether the episode is hosted outside of Spotify's CDN. | ||
| * | ||
| * @return True if the episode is hosted outside of Spotify's CDN. | ||
| */ | ||
| Boolean getExternallyHosted(); | ||
|
|
||
| /** | ||
| * Check whether the episode is playable in the given market. | ||
| * | ||
| * @return True if the episode is playable in the given market. Otherwise false. | ||
| */ | ||
| Boolean getPlayable(); | ||
|
|
||
| /** | ||
| * Get a list of the languages used in the episode, identified by their ISO 639 code. | ||
| * | ||
| * @return An array of <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2 country codes</a>. | ||
| */ | ||
| String[] getLanguages(); | ||
|
|
||
| /** | ||
| * Get the date the episode was first released, for example "1981-12-15". Depending on the precision, it might be shown as "1981" or "1981-12". | ||
| * | ||
| * @return The release date of the episode. | ||
| */ | ||
| String getReleaseDate(); | ||
|
|
||
| /** | ||
| * Get the precision with which the release date is known. | ||
| * | ||
| * @return A {@link ReleaseDatePrecision} object. | ||
| */ | ||
| ReleaseDatePrecision getReleaseDatePrecision(); | ||
|
|
||
| /** | ||
| * Get the user's most recent position in the episode. Set if the supplied access token is a user token and has the scope {@code user-read-playback-position}. | ||
| * | ||
| * @return A {@link ResumePoint} object. | ||
| */ | ||
| ResumePoint getResumePoint(); | ||
| } | ||
|
|
||
|
|
||
17 changes: 17 additions & 0 deletions
17
src/main/java/se/michaelthelin/spotify/model_objects/interfaces/IHasTotal.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package se.michaelthelin.spotify.model_objects.interfaces; | ||
|
|
||
| /** | ||
| * Represents an object that has a total count. | ||
| * <p> | ||
| * This interface is implemented by objects that provide a total count of items, | ||
| * such as playlists or other paging objects. | ||
| */ | ||
| public interface IHasTotal { | ||
| /** | ||
| * Get the total count. | ||
| * | ||
| * @return The total count of items | ||
| */ | ||
| Integer getTotal(); | ||
| } | ||
|
|
128 changes: 128 additions & 0 deletions
128
src/main/java/se/michaelthelin/spotify/model_objects/interfaces/IPlaylist.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| package se.michaelthelin.spotify.model_objects.interfaces; | ||
|
|
||
| import se.michaelthelin.spotify.enums.ModelObjectType; | ||
| import se.michaelthelin.spotify.model_objects.specification.ExternalUrl; | ||
| import se.michaelthelin.spotify.model_objects.specification.Image; | ||
| import se.michaelthelin.spotify.model_objects.specification.Playlist; | ||
| import se.michaelthelin.spotify.model_objects.specification.PlaylistSimplified; | ||
| import se.michaelthelin.spotify.model_objects.specification.User; | ||
|
|
||
| /** | ||
| * Represents the common properties of Spotify Playlist objects (full and simplified). | ||
| * | ||
| * <p>This interface provides a common base for {@link Playlist} and | ||
| * {@link PlaylistSimplified} objects. | ||
| * | ||
| * @param <T> The concrete type of the items/tracks metadata object. {@link Playlist} uses | ||
| * {@link se.michaelthelin.spotify.model_objects.specification.Paging} and | ||
| * {@link PlaylistSimplified} uses | ||
| * {@link se.michaelthelin.spotify.model_objects.miscellaneous.PlaylistTracksInformation}. | ||
| */ | ||
| public interface IPlaylist<T extends IHasTotal> { | ||
| /** | ||
| * Check whether the owner allows other users to modify the playlist. | ||
| * | ||
| * @return {@code true} if other users are allowed to modify the playlist, {@code false} otherwise. | ||
| * @see <a href="https://developer.spotify.com/documentation/web-api/concepts/playlists"> | ||
| * Spotify: Working With Playlists</a> | ||
| */ | ||
| Boolean getIsCollaborative(); | ||
|
|
||
| /** | ||
| * Get the description of the playlist. | ||
| * | ||
| * @return The playlist description. Only returned for modified, verified playlists, otherwise {@code null}. | ||
| */ | ||
| String getDescription(); | ||
|
|
||
| /** | ||
| * Get the external URLs of the playlist. <br> | ||
| * Example: Spotify-URL. | ||
| * | ||
| * @return Known external URLs for this playlist. | ||
| */ | ||
| ExternalUrl getExternalUrls(); | ||
|
|
||
| /** | ||
| * Get the full Spotify API endpoint url of the playlist. | ||
| * | ||
| * @return A link to the Web API endpoint providing full details of the playlist. | ||
| */ | ||
| String getHref(); | ||
|
|
||
| /** | ||
| * Get the <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify ID</a> | ||
| * of a playlist. | ||
| * | ||
| * @return The Spotify ID for the playlist. | ||
| */ | ||
| String getId(); | ||
|
|
||
| /** | ||
| * Images for the playlist. The array may be empty or contain up to three images. The images are returned by size in | ||
| * descending order. <br> | ||
| * <b>Note:</b> If returned, the source URL for the image is temporary and will expire in less than a day. | ||
| * | ||
| * @return An array of images in different sizes. | ||
| * @see <a href="https://developer.spotify.com/documentation/web-api/concepts/playlists"> | ||
| * Spotify: Working With Playlists</a> | ||
| */ | ||
| Image[] getImages(); | ||
|
|
||
| /** | ||
| * Get the name of a playlist. | ||
| * | ||
| * @return Playlist name. | ||
| */ | ||
| String getName(); | ||
|
|
||
| /** | ||
| * Get the owners user object of a playlist. | ||
| * | ||
| * @return A user object. | ||
| */ | ||
| User getOwner(); | ||
|
|
||
| /** | ||
| * Check whether a playlist is available in public or is private. | ||
| * | ||
| * @return {@code true} the playlist is public, {@code false} the playlist is private, {@code null} | ||
| * the playlist status is not relevant. | ||
| * @see <a href="https://developer.spotify.com/documentation/web-api/concepts/playlists"> | ||
| * Spotify: Working With Playlists</a> | ||
| */ | ||
| Boolean getIsPublicAccess(); | ||
|
|
||
| /** | ||
| * Get information about the items in the playlist. The concrete type depends on the specific playlist object type. | ||
| * | ||
| * @return Item information containing total count. | ||
| */ | ||
| T getItems(); | ||
|
|
||
| /** | ||
| * Get the snapshot ID, the version identifier for the current playlist. Can be supplied in other requests to target | ||
| * a specific playlist version. | ||
| * | ||
| * @return The version identifier for the current playlist. | ||
| * @see se.michaelthelin.spotify.requests.data.playlists.RemoveItemsFromPlaylistRequest | ||
| */ | ||
| String getSnapshotId(); | ||
|
|
||
| /** | ||
| * Get the model object type. In this case "playlist". | ||
| * | ||
| * @return The object type: "playlist" | ||
| */ | ||
| ModelObjectType getType(); | ||
|
|
||
| /** | ||
| * Get the <a href="https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids">Spotify URI</a> | ||
| * of a playlist. | ||
| * | ||
| * @return Spotify playlist URI. | ||
| */ | ||
| String getUri(); | ||
| } | ||
|
|
||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.