(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .type(type);
- }
-
- /**
- * Get the current user's top artists based on calculated affinity.
- *
- * @return A {@link GetUsersTopArtistsRequest.Builder}.
- * @see #getUsersTopArtistsAndTracks(ModelObjectType)
- */
- public GetUsersTopArtistsRequest.Builder getUsersTopArtists() {
- return new GetUsersTopArtistsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get the current user's top tracks based on calculated affinity.
- *
- * @return A {@link GetUsersTopTracksRequest.Builder}.
- * @see #getUsersTopArtistsAndTracks(ModelObjectType)
- */
- public GetUsersTopTracksRequest.Builder getUsersTopTracks() {
- return new GetUsersTopTracksRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get information about the user's current playback state, including context, track progress, and active device.
- *
- * @return A {@link GetInformationAboutUsersCurrentPlaybackRequest.Builder}.
- */
- public GetInformationAboutUsersCurrentPlaybackRequest.Builder getInformationAboutUsersCurrentPlayback() {
- return new GetInformationAboutUsersCurrentPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get tracks from the current user's recently played tracks.
- *
- * Returns the most recent 50 tracks played by an user. Note that a track currently playing will not be visible in play
- * history until it has completed. A track must be played for more than 30 seconds to be included in play history.
- *
- * Any tracks listened to while the user had "Private Session" enabled in their client will not be returned in the
- * list of recently played tracks.
- *
- * @return A {@link GetCurrentUsersRecentlyPlayedTracksRequest.Builder}.
- */
- public GetCurrentUsersRecentlyPlayedTracksRequest.Builder getCurrentUsersRecentlyPlayedTracks() {
- return new GetCurrentUsersRecentlyPlayedTracksRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get information about an user's available devices.
- *
- * @return A {@link GetUsersAvailableDevicesRequest.Builder}.
- */
- public GetUsersAvailableDevicesRequest.Builder getUsersAvailableDevices() {
- return new GetUsersAvailableDevicesRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get the object currently being played on the user's Spotify account.
- *
- * @return A {@link GetUsersCurrentlyPlayingTrackRequest.Builder}.
- */
- public GetUsersCurrentlyPlayingTrackRequest.Builder getUsersCurrentlyPlayingTrack() {
- return new GetUsersCurrentlyPlayingTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Pause playback on the user's account.
- *
- * @return A {@link PauseUsersPlaybackRequest.Builder}.
- */
- public PauseUsersPlaybackRequest.Builder pauseUsersPlayback() {
- return new PauseUsersPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Seeks to the given position in the user's currently playing track.
- *
- * @param position_ms The position in milliseconds to seek to. Must be a positive number. Passing in a position that
- * is greater than the length of the track will cause the player to start playing the next song.
- * @return A {@link SeekToPositionInCurrentlyPlayingTrackRequest.Builder}.
- */
- public SeekToPositionInCurrentlyPlayingTrackRequest.Builder seekToPositionInCurrentlyPlayingTrack(int position_ms) {
- return new SeekToPositionInCurrentlyPlayingTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .position_ms(position_ms);
- }
-
- /**
- * Set the repeat mode for the user's playback. Options are repeat-track, repeat-context, and off.
- *
- * @param state track, context or off. track will repeat the current track. context will repeat the current
- * context. off will turn repeat off.
- * @return A {@link SetRepeatModeOnUsersPlaybackRequest.Builder}.
- */
- public SetRepeatModeOnUsersPlaybackRequest.Builder setRepeatModeOnUsersPlayback(String state) {
- return new SetRepeatModeOnUsersPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .state(state);
- }
-
- /**
- * Set the volume for the user's current playback device.
- *
- * @param volume_percent Integer. The volume to set. Must be a value from 0 to 100 inclusive.
- * @return A {@link SetVolumeForUsersPlaybackRequest.Builder}.
- */
- public SetVolumeForUsersPlaybackRequest.Builder setVolumeForUsersPlayback(int volume_percent) {
- return new SetVolumeForUsersPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .volume_percent(volume_percent);
- }
-
- /**
- * Skips to next track in the user's queue.
- *
- * @return A {@link SkipUsersPlaybackToNextTrackRequest.Builder}.
- */
- public SkipUsersPlaybackToNextTrackRequest.Builder skipUsersPlaybackToNextTrack() {
- return new SkipUsersPlaybackToNextTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Skips to previous track in the user's queue.
- *
- * Note: This will ALWAYS skip to the previous track, regardless of the current track’s progress. Returning to
- * the start of the current track should be performed using the {@link #seekToPositionInCurrentlyPlayingTrack(int)}
- * method.
- *
- * @return A {@link SkipUsersPlaybackToPreviousTrackRequest.Builder}.
- */
- public SkipUsersPlaybackToPreviousTrackRequest.Builder skipUsersPlaybackToPreviousTrack() {
- return new SkipUsersPlaybackToPreviousTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Start a new context or resume current playback on the user's active device.
- *
- * @return A {@link StartResumeUsersPlaybackRequest.Builder}.
- */
- public StartResumeUsersPlaybackRequest.Builder startResumeUsersPlayback() {
- return new StartResumeUsersPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Toggle shuffle on or off for user's playback.
- *
- * @param state true: Shuffle user's playback. false: Do not shuffle user's playback.
- * @return A {@link ToggleShuffleForUsersPlaybackRequest.Builder}.
- */
- public ToggleShuffleForUsersPlaybackRequest.Builder toggleShuffleForUsersPlayback(boolean state) {
- return new ToggleShuffleForUsersPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .state(state);
- }
-
- /**
- * Transfer playback to a new device and determine if it should start playing.
- *
- * @param device_ids A JSON array containing the ID of the device on which playback should be started/transferred.
- *
Note: Although an array is accepted, only a single device_id is currently supported.
- * @return A {@link TransferUsersPlaybackRequest.Builder}.
- */
- public TransferUsersPlaybackRequest.Builder transferUsersPlayback(JsonArray device_ids) {
- return new TransferUsersPlaybackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .device_ids(device_ids);
- }
-
- /**
- * Add a track or an episode to the end of the user's current playback queue.
- *
- * @param uri The uri of the item to add to the queue. Must be a track or an episode uri.
- * @return A {@link AddItemToUsersPlaybackQueueRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public AddItemToUsersPlaybackQueueRequest.Builder addItemToUsersPlaybackQueue(String uri) {
- return new AddItemToUsersPlaybackQueueRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .uri(uri);
- }
-
- /**
- * Add items to a playlist.
- *
- * @param user_id The owners username.
- * @param playlist_id The playlists ID.
- * @param uris URIs of the tracks or episodes to add. Maximum: 100 item URIs.
- * @return An {@link AddItemsToPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public AddItemsToPlaylistRequest.Builder addItemsToPlaylist(String user_id, String playlist_id, String[] uris) {
- return new AddItemsToPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id)
- .uris(concat(uris, ','));
- }
-
- /**
- * Add items to a playlist.
- *
- * Note: If you want to add a large number of items (>50), use {@link #addItemsToPlaylist(String, JsonArray)} to not exceed
- * the maximum URI length.
- * @param playlist_id The playlists ID.
- * @param uris URIs of the tracks or episodes to add. Maximum: 100 item URIs.
- * @return An {@link AddItemsToPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public AddItemsToPlaylistRequest.Builder addItemsToPlaylist(String playlist_id, String[] uris) {
- return new AddItemsToPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id)
- .uris(concat(uris, ','));
- }
-
- /**
- * Add items to a playlist.
- *
- * @param user_id The owners username.
- * @param playlist_id The playlists ID.
- * @param uris URIs of the tracks or episodes to add. Maximum: 100 item URIs.
- * @return An {@link AddItemsToPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public AddItemsToPlaylistRequest.Builder addItemsToPlaylist(String user_id, String playlist_id, JsonArray uris) {
- return new AddItemsToPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id)
- .uris(uris);
- }
-
- /**
- * Add items to a playlist.
- *
- * @param playlist_id The playlists ID.
- * @param uris URIs of the tracks or episodes to add. Maximum: 100 item URIs.
- * @return An {@link AddItemsToPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public AddItemsToPlaylistRequest.Builder addItemsToPlaylist(String playlist_id, JsonArray uris) {
- return new AddItemsToPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id)
- .uris(uris);
- }
-
- /**
- * Update a playlists properties.
- *
- * @param user_id The owners username.
- * @param playlist_id The playlists ID.
- * @return A {@link ChangePlaylistsDetailsRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public ChangePlaylistsDetailsRequest.Builder changePlaylistsDetails(String user_id, String playlist_id) {
- return new ChangePlaylistsDetailsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id);
- }
-
- /**
- * Update a playlists properties.
- *
- * @param playlist_id The playlists ID.
- * @return A {@link ChangePlaylistsDetailsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public ChangePlaylistsDetailsRequest.Builder changePlaylistsDetails(String playlist_id) {
- return new ChangePlaylistsDetailsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id);
- }
-
- /**
- * Create a playlist.
- *
- * @param user_id The playlists owner.
- * @param name The name of the playlist.
- * @return A {@link CreatePlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public CreatePlaylistRequest.Builder createPlaylist(String user_id, String name) {
- return new CreatePlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .name(name);
- }
-
- /**
- * Get a list of the playlists owned or followed by the current Spotify user.
- *
- * @return A {@link GetListOfCurrentUsersPlaylistsRequest.Builder}.
- */
- public GetListOfCurrentUsersPlaylistsRequest.Builder getListOfCurrentUsersPlaylists() {
- return new GetListOfCurrentUsersPlaylistsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get an user's playlists.
- *
- * @param user_id A Spotify ID of the user.
- * @return A {@link GetListOfUsersPlaylistsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetListOfUsersPlaylistsRequest.Builder getListOfUsersPlaylists(String user_id) {
- return new GetListOfUsersPlaylistsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id);
- }
-
- /**
- * Get a playlist.
- *
- * @param user_id The playlists owners username.
- * @param playlist_id The playlists ID.
- * @return A {@link GetPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public GetPlaylistRequest.Builder getPlaylist(String user_id, String playlist_id) {
- return new GetPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id);
- }
-
- /**
- * Get a playlist.
- *
- * @param playlist_id The playlists ID.
- * @return A {@link GetPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetPlaylistRequest.Builder getPlaylist(String playlist_id) {
- return new GetPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id);
- }
-
- /**
- * Get the image used to represent a specific playlist.
- *
- * @param user_id The user's Spotify user ID.
- * @param playlist_id The Spotify ID for the playlist.
- * @return A {@link GetPlaylistCoverImageRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public GetPlaylistCoverImageRequest.Builder getPlaylistCoverImage(String user_id, String playlist_id) {
- return new GetPlaylistCoverImageRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id);
- }
-
- /**
- * Get the image used to represent a specific playlist.
- *
- * @param playlist_id The Spotify ID for the playlist.
- * @return A {@link GetPlaylistCoverImageRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetPlaylistCoverImageRequest.Builder getPlaylistCoverImage(String playlist_id) {
- return new GetPlaylistCoverImageRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id);
- }
-
- /**
- * Get a playlists items.
- *
- * @param user_id The playlists owners username.
- * @param playlist_id The playlists ID.
- * @return A {@link GetPlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public GetPlaylistsItemsRequest.Builder getPlaylistsItems(String user_id, String playlist_id) {
- return new GetPlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id);
- }
-
- /**
- * Get a playlist's items.
- *
- * @param playlist_id The playlists ID.
- * @return A {@link GetPlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetPlaylistsItemsRequest.Builder getPlaylistsItems(String playlist_id) {
- return new GetPlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id);
- }
-
- /**
- * Delete items from a playlist
- *
- * @param user_id The owners username.
- * @param playlist_id The playlists ID.
- * @param tracks URIs of the items to remove. Maximum: 100 track or episode URIs.
- * @return A {@link RemoveItemsFromPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public RemoveItemsFromPlaylistRequest.Builder removeItemsFromPlaylist(
- String user_id, String playlist_id, JsonArray tracks) {
- return new RemoveItemsFromPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id)
- .tracks(tracks);
- }
-
- /**
- * Delete items from a playlist
- *
- * @param playlist_id The playlists ID.
- * @param tracks URIs of the items to remove. Maximum: 100 track or episode URIs.
- * @return A {@link RemoveItemsFromPlaylistRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public RemoveItemsFromPlaylistRequest.Builder removeItemsFromPlaylist(
- String playlist_id, JsonArray tracks) {
- return new RemoveItemsFromPlaylistRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id)
- .tracks(tracks);
- }
-
- /**
- * Reorder a item or a group of items in a playlist.
- *
- * When reordering items, the timestamp indicating when they were added and the user who added them will be kept
- * untouched. In addition, the users following the playlists won’t be notified about changes in the playlists when the
- * items are reordered.
- *
- * @param user_id The user's Spotify user ID.
- * @param playlist_id The Spotify ID for the playlist.
- * @param range_start The position of the first item to be reordered.
- * @param insert_before The position where the items should be inserted. To reorder the items to the end of the
- * playlist, simply set insert_before to the position after the last item.
- * @return A {@link ReorderPlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public ReorderPlaylistsItemsRequest.Builder reorderPlaylistsItems(String user_id, String playlist_id, int range_start, int insert_before) {
- return new ReorderPlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id)
- .range_start(range_start)
- .insert_before(insert_before);
- }
-
- /**
- * Reorder an item or a group of items in a playlist.
- *
- * When reordering items, the timestamp indicating when they were added and the user who added them will be kept
- * untouched. In addition, the users following the playlists won’t be notified about changes in the playlists when the
- * items are reordered.
- *
- * @param playlist_id The Spotify ID for the playlist.
- * @param range_start The position of the first item to be reordered.
- * @param insert_before The position where the items should be inserted. To reorder the items to the end of the
- * playlist, simply set insert_before to the position after the last item.
- * @return A {@link ReorderPlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public ReorderPlaylistsItemsRequest.Builder reorderPlaylistsItems(String playlist_id, int range_start, int insert_before) {
- return new ReorderPlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id)
- .range_start(range_start)
- .insert_before(insert_before);
- }
-
- /**
- * Replace items in a playlist.
- *
- * @param user_id The owners username.
- * @param playlist_id The playlists ID.
- * @param uris URIs of the items to add. Maximum: 100 track or episode URIs.
- * @return A {@link ReplacePlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public ReplacePlaylistsItemsRequest.Builder replacePlaylistsItems(String user_id, String playlist_id, String[] uris) {
- return new ReplacePlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id)
- .uris(concat(uris, ','));
- }
-
- /**
- * Replace items in a playlist.
- *
- * @param playlist_id The playlists ID.
- * @param uris URIs of the items to set. Maximum: 100 track or episode URIs.
- * @return A {@link ReplacePlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public ReplacePlaylistsItemsRequest.Builder replacePlaylistsItems(String playlist_id, String[] uris) {
- return new ReplacePlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id)
- .uris(concat(uris, ','));
- }
-
- /**
- * Replace items in a playlist.
- *
- * @param user_id The owners username.
- * @param playlist_id The playlists ID.
- * @param uris URIs of the items to add. Maximum: 100 track or episode URIs.
- * @return A {@link ReplacePlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public ReplacePlaylistsItemsRequest.Builder replacePlaylistsItems(String user_id, String playlist_id, JsonArray uris) {
- return new ReplacePlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id)
- .uris(uris);
- }
-
- /**
- * Replace items in a playlist.
- *
- * @param playlist_id The playlists ID.
- * @param uris URIs of the items to add. Maximum: 100 track or episode URIs.
- * @return A {@link ReplacePlaylistsItemsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public ReplacePlaylistsItemsRequest.Builder replacePlaylistsItems(String playlist_id, JsonArray uris) {
- return new ReplacePlaylistsItemsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id)
- .uris(uris);
- }
-
- /**
- * Replace the image used to represent a specific playlist.
- *
- * @param user_id The user's Spotify user ID.
- * @param playlist_id The Spotify ID for the playlist.
- * @return An {@link UploadCustomPlaylistCoverImageRequest.Builder}.
- * @see Spotify: URLs & IDs
- * @deprecated Playlist IDs are unique for themselves. This parameter is thus no longer used.
- * (https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/)
- */
- @Deprecated
- public UploadCustomPlaylistCoverImageRequest.Builder uploadCustomPlaylistCoverImage(String user_id, String playlist_id) {
- return new UploadCustomPlaylistCoverImageRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id)
- .playlist_id(playlist_id);
- }
-
- /**
- * Replace the image used to represent a specific playlist.
- *
- * @param playlist_id The Spotify ID for the playlist.
- * @return An {@link UploadCustomPlaylistCoverImageRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public UploadCustomPlaylistCoverImageRequest.Builder uploadCustomPlaylistCoverImage(String playlist_id) {
- return new UploadCustomPlaylistCoverImageRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .playlist_id(playlist_id);
- }
-
- /**
- * Get Spotify catalog information about artists, albums, episodes, shows, tracks or playlists that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @param type A comma-separated list of item types to search across. Valid types are: album, artist, episode, show, playlist and
- * track.
- * @return A {@link SearchItemRequest.Builder}.
- */
- public SearchItemRequest.Builder searchItem(String q, String type) {
- return new SearchItemRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q)
- .type(type);
- }
-
- /**
- * Get Spotify catalog information about albums that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchAlbumsRequest.Builder}.
- */
- public SearchAlbumsRequest.Builder searchAlbums(String q) {
- return new SearchAlbumsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get Spotify catalog information about albums that match a keyword string.
- *
- * This method exists because the searches API returns the undocumented property {@code totalTracks}, which is
- * included by this method's return type.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchAlbumsSpecialRequest.Builder}.
- */
- public SearchAlbumsSpecialRequest.Builder searchAlbumsSpecial(String q) {
- return new SearchAlbumsSpecialRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get Spotify catalog information about artists that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchArtistsRequest.Builder}.
- */
- public SearchArtistsRequest.Builder searchArtists(String q) {
- return new SearchArtistsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get Spotify catalog information about episodes that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchEpisodesRequest.Builder}.
- */
- public SearchEpisodesRequest.Builder searchEpisodes(String q) {
- return new SearchEpisodesRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get Spotify catalog information about playlists that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchPlaylistsRequest.Builder}.
- */
- public SearchPlaylistsRequest.Builder searchPlaylists(String q) {
- return new SearchPlaylistsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get Spotify catalog information about shows that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchShowsRequest.Builder}.
- */
- public SearchShowsRequest.Builder searchShows(String q) {
- return new SearchShowsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get Spotify catalog information about tracks that match a keyword string.
- *
- * @param q The search query's keywords (and optional field filters and operators).
- * @return A {@link SearchTracksRequest.Builder}.
- */
- public SearchTracksRequest.Builder searchTracks(String q) {
- return new SearchTracksRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .q(q);
- }
-
- /**
- * Get a show.
- *
- * @param id The Spotify ID of the show.
- * @return A {@link GetShowRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetShowRequest.Builder getShow(String id) {
- return new GetShowRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .id(id);
- }
-
- /**
- * Get multiple shows.
- *
- * @param ids The Spotify IDs of all shows you're trying to retrieve. Maximum: 50 IDs.
- * @return A {@link GetSeveralShowsRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetSeveralShowsRequest.Builder getSeveralShows(String... ids) {
- return new GetSeveralShowsRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .ids(concat(ids, ','));
- }
-
- /**
- * Get Spotify catalog information about an show’s episodes.
- *
- * @param id The Spotify ID of the show.
- * @return A {@link GetShowsEpisodesRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetShowsEpisodesRequest.Builder getShowEpisodes(String id) {
- return new GetShowsEpisodesRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .id(id);
- }
-
- /**
- * Get a detailed audio analysis for a single track identified by its unique Spotify ID.
- *
- * @param id The Spotify ID for the track.
- * @return A {@link GetAudioAnalysisForTrackRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetAudioAnalysisForTrackRequest.Builder getAudioAnalysisForTrack(String id) {
- return new GetAudioAnalysisForTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .id(id);
- }
-
- /**
- * Get audio features for a track based on its Spotify ID.
- *
- * @param id The Spotify ID of the track.
- * @return A {@link GetAudioFeaturesForTrackRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetAudioFeaturesForTrackRequest.Builder getAudioFeaturesForTrack(String id) {
- return new GetAudioFeaturesForTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .id(id);
- }
-
- /**
- * Get audio features for multiple tracks based on their Spotify IDs.
- *
- * @param ids A comma-separated list of the Spotify IDs for the tracks. Maximum: 100 IDs.
- * @return A {@link GetAudioFeaturesForSeveralTracksRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetAudioFeaturesForSeveralTracksRequest.Builder getAudioFeaturesForSeveralTracks(String... ids) {
- return new GetAudioFeaturesForSeveralTracksRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .ids(concat(ids, ','));
- }
-
- /**
- * Get multiple tracks.
- *
- * @param ids The Spotify IDs of all tracks you're trying to retrieve. Maximum: 50 IDs.
- * @return A {@link GetSeveralTracksRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetSeveralTracksRequest.Builder getSeveralTracks(String... ids) {
- return new GetSeveralTracksRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .ids(concat(ids, ','));
- }
-
- /**
- * Get a track.
- *
- * @param id The Spotify ID of the track.
- * @return A {@link GetTrackRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetTrackRequest.Builder getTrack(String id) {
- return new GetTrackRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .id(id);
- }
-
- /**
- * Get detailed profile information about the current user (including the current user’s username).
- *
- * @return A {@link GetCurrentUsersProfileRequest.Builder}.
- */
- public GetCurrentUsersProfileRequest.Builder getCurrentUsersProfile() {
- return new GetCurrentUsersProfileRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port);
- }
-
- /**
- * Get public profile information about a Spotify user.
- *
- * @param user_id The Spotify ID of the user.
- * @return A {@link GetUsersProfileRequest.Builder}.
- * @see Spotify: URLs & IDs
- */
- public GetUsersProfileRequest.Builder getUsersProfile(String user_id) {
- return new GetUsersProfileRequest.Builder(accessToken)
- .setDefaults(httpManager, scheme, host, port)
- .user_id(user_id);
- }
-
- /**
- * Builder class for building {@link SpotifyApi} instances.
- */
- public static class Builder {
-
- private IHttpManager httpManager = DEFAULT_HTTP_MANAGER;
- private String scheme = DEFAULT_SCHEME;
- private String host = DEFAULT_HOST;
- private Integer port = DEFAULT_PORT;
- private String proxyUrl;
- private Integer proxyPort;
- private Integer proxyUsername;
- private Integer proxyPassword;
- private String clientId;
- private String clientSecret;
- private URI redirectUri;
- private String accessToken;
- private String refreshToken;
-
- /**
- * The HttpManager setter.
- *
- * @param httpManager A Spotify HttpManager.
- * @return A {@link Builder}.
- */
- public Builder setHttpManager(IHttpManager httpManager) {
- this.httpManager = httpManager;
- return this;
- }
-
- /**
- * The scheme setter.
- *
- * @param scheme A HTTP-scheme.
- * @return A {@link Builder}.
- */
- public Builder setScheme(String scheme) {
- this.scheme = scheme;
- return this;
- }
-
- /**
- * The Spotify API host setter.
- *
- * @param host A Spotify API host.
- * @return A {@link Builder}.
- */
- public Builder setHost(String host) {
- this.host = host;
- return this;
- }
-
- /**
- * The Spotify API port setter.
- *
- * @param port A Spotify API port.
- * @return A {@link Builder}.
- */
- public Builder setPort(Integer port) {
- this.port = port;
- return this;
- }
-
- /**
- * The proxy URL setter.
- *
- * @param proxyUrl A proxy URL.
- * @return A {@link Builder}.
- */
- public Builder setProxyUrl(String proxyUrl) {
- this.proxyUrl = proxyUrl;
- return this;
- }
-
- /**
- * The proxy port setter.
- *
- * @param proxyPort A proxy port.
- * @return A {@link Builder}.
- */
- public Builder setProxyPort(Integer proxyPort) {
- this.proxyPort = proxyPort;
- return this;
- }
-
- /**
- * The proxy username setter.
- *
- * @param proxyUsername A proxy username.
- * @return A {@link Builder}.
- */
- public Builder setProxyUsername(Integer proxyUsername) {
- this.proxyUsername = proxyUsername;
- return this;
- }
-
- /**
- * The proxy password setter.
- *
- * @param proxyPassword A proxy password.
- * @return A {@link Builder}.
- */
- public Builder setProxyPassword(Integer proxyPassword) {
- this.proxyPassword = proxyPassword;
- return this;
- }
-
- /**
- * The client ID setter.
- *
- * @param clientId A client ID of your application.
- * @return A {@link Builder}.
- */
- public Builder setClientId(String clientId) {
- this.clientId = clientId;
- return this;
- }
-
- /**
- * The client secret setter.
- *
- * @param clientSecret A client secret of your application.
- * @return A {@link Builder}.
- */
- public Builder setClientSecret(String clientSecret) {
- this.clientSecret = clientSecret;
- return this;
- }
-
- /**
- * The redirect URI setter.
- *
- * @param redirectUri A redirect URI of your application.
- * @return A {@link Builder}.
- */
- public Builder setRedirectUri(URI redirectUri) {
- this.redirectUri = redirectUri;
- return this;
- }
-
- /**
- * The access token setter.
- *
- * @param accessToken A Spotify API access token.
- * @return A {@link Builder}.
- */
- public Builder setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- return this;
- }
-
- /**
- * The refresh token setter.
- *
- * @param refreshToken A Spotify API refresh token.
- * @return A {@link Builder}.
- */
- public Builder setRefreshToken(String refreshToken) {
- this.refreshToken = refreshToken;
- return this;
- }
-
- /**
- * Build a {@link SpotifyApi} instance with the information given to the builder.
- *
- * @return A {@link SpotifyApi} instance.
- */
- public SpotifyApi build() {
- return new SpotifyApi(this);
- }
- }
-}
-
--- 'a/spotify/src/main/java/com/stream_pi/spotify/SpotifyApiThreading.java'
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.wrapper.spotify;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class SpotifyApiThreading {
-
- public static final ExecutorService THREADPOOL = Executors.newCachedThreadPool();
-
- public static CompletableFuture executeAsync(final Callable callable) {
- CompletableFuture future = new CompletableFuture<>();
-
- SpotifyApiThreading.THREADPOOL.execute(() -> {
- try {
- future.complete(callable.call());
- } catch (Exception e) {
- future.completeExceptionally(e);
- }
- });
-
- return future;
- }
-
-}
-
--- 'a/spotify/src/main/java/com/stream_pi/spotify/SpotifyHttpManager.java'
+++ /dev/null
@@ -1,395 +0,0 @@
-package com.wrapper.spotify;
-
-import com.google.gson.*;
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-import com.wrapper.spotify.exceptions.detailed.*;
-import org.apache.hc.client5.http.auth.AuthScope;
-import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
-import org.apache.hc.client5.http.cache.CacheResponseStatus;
-import org.apache.hc.client5.http.cache.HttpCacheContext;
-import org.apache.hc.client5.http.classic.methods.HttpDelete;
-import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.classic.methods.HttpPost;
-import org.apache.hc.client5.http.classic.methods.HttpPut;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.client5.http.cookie.StandardCookieSpec;
-import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
-import org.apache.hc.client5.http.impl.cache.CacheConfig;
-import org.apache.hc.client5.http.impl.cache.CachingHttpClients;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
-import org.apache.hc.client5.http.impl.classic.HttpClients;
-import org.apache.hc.core5.http.*;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.util.Timeout;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.logging.Level;
-
-public class SpotifyHttpManager implements IHttpManager {
-
- private static final int DEFAULT_CACHE_MAX_ENTRIES = 1000;
- private static final int DEFAULT_CACHE_MAX_OBJECT_SIZE = 8192;
- private static final Gson GSON = new Gson();
- private final CloseableHttpClient httpClient;
- private final CloseableHttpClient httpClientCaching;
- private final HttpHost proxy;
- private final UsernamePasswordCredentials proxyCredentials;
- private final Integer cacheMaxEntries;
- private final Integer cacheMaxObjectSize;
- private final Integer connectionRequestTimeout;
- private final Integer connectTimeout;
- private final Integer socketTimeout;
-
- /**
- * Construct a new SpotifyHttpManager instance.
- *
- * @param builder The builder.
- */
- public SpotifyHttpManager(Builder builder) {
- this.proxy = builder.proxy;
- this.proxyCredentials = builder.proxyCredentials;
- this.cacheMaxEntries = builder.cacheMaxEntries;
- this.cacheMaxObjectSize = builder.cacheMaxObjectSize;
- this.connectionRequestTimeout = builder.connectionRequestTimeout;
- this.connectTimeout = builder.connectTimeout;
- this.socketTimeout = builder.socketTimeout;
-
- CacheConfig cacheConfig = CacheConfig.custom()
- .setMaxCacheEntries(cacheMaxEntries != null ? cacheMaxEntries : DEFAULT_CACHE_MAX_ENTRIES)
- .setMaxObjectSize(cacheMaxObjectSize != null ? cacheMaxObjectSize : DEFAULT_CACHE_MAX_OBJECT_SIZE)
- .setSharedCache(false)
- .build();
-
- BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-
- if (proxy != null) {
- credentialsProvider.setCredentials(
- new AuthScope(null, proxy.getHostName(), proxy.getPort(), null, proxy.getSchemeName()),
- proxyCredentials
- );
- }
-
- RequestConfig requestConfig = RequestConfig
- .custom()
- .setCookieSpec(StandardCookieSpec.STRICT)
- .setProxy(proxy)
- .setConnectionRequestTimeout(builder.connectionRequestTimeout != null
- ? Timeout.ofMilliseconds(builder.connectionRequestTimeout)
- : RequestConfig.DEFAULT.getConnectionRequestTimeout())
- .setConnectTimeout(builder.connectTimeout != null
- ? Timeout.ofMilliseconds(builder.connectTimeout)
- : RequestConfig.DEFAULT.getConnectTimeout())
- .setResponseTimeout(builder.socketTimeout != null
- ? Timeout.ofMilliseconds(builder.socketTimeout)
- : RequestConfig.DEFAULT.getResponseTimeout())
- .build();
-
- this.httpClient = HttpClients
- .custom()
- .setDefaultCredentialsProvider(credentialsProvider)
- .setDefaultRequestConfig(requestConfig)
- .disableContentCompression()
- .build();
-
- this.httpClientCaching = CachingHttpClients
- .custom()
- .setCacheConfig(cacheConfig)
- .setDefaultCredentialsProvider(credentialsProvider)
- .setDefaultRequestConfig(requestConfig)
- .disableContentCompression()
- .build();
- }
-
- public static URI makeUri(String uriString) {
- try {
- return new URI(uriString);
- } catch (URISyntaxException e) {
- SpotifyApi.LOGGER.log(
- Level.SEVERE,
- "URI Syntax Exception for \"" + uriString + "\"");
- return null;
- }
- }
-
- public HttpHost getProxy() {
- return proxy;
- }
-
- public UsernamePasswordCredentials getProxyCredentials() {
- return proxyCredentials;
- }
-
- public Integer getCacheMaxEntries() {
- return cacheMaxEntries;
- }
-
- public Integer getCacheMaxObjectSize() {
- return cacheMaxObjectSize;
- }
-
- public Integer getConnectionRequestTimeout() {
- return connectionRequestTimeout;
- }
-
- public Integer getConnectTimeout() {
- return connectTimeout;
- }
-
- public Integer getSocketTimeout() {
- return socketTimeout;
- }
-
- @Override
- public String get(URI uri, Header[] headers) throws
- IOException,
- SpotifyWebApiException,
- ParseException {
- assert (uri != null);
- assert (!uri.toString().equals(""));
-
- final HttpGet httpGet = new HttpGet(uri);
-
- httpGet.setHeaders(headers);
- SpotifyApi.LOGGER.log(
- Level.FINE,
- "GET request uses these headers: " + GSON.toJson(headers));
-
- String responseBody = getResponseBody(execute(httpClientCaching, httpGet));
-
- httpGet.reset();
-
- return responseBody;
- }
-
- @Override
- public String post(URI uri, Header[] headers, HttpEntity body) throws
- IOException,
- SpotifyWebApiException,
- ParseException {
- assert (uri != null);
- assert (!uri.toString().equals(""));
-
- final HttpPost httpPost = new HttpPost(uri);
-
- httpPost.setHeaders(headers);
- httpPost.setEntity(body);
- SpotifyApi.LOGGER.log(
- Level.FINE,
- "POST request uses these headers: " + GSON.toJson(headers));
-
- String responseBody = getResponseBody(execute(httpClient, httpPost));
-
- httpPost.reset();
-
- return responseBody;
- }
-
- @Override
- public String put(URI uri, Header[] headers, HttpEntity body) throws
- IOException,
- SpotifyWebApiException,
- ParseException {
- assert (uri != null);
- assert (!uri.toString().equals(""));
-
- final HttpPut httpPut = new HttpPut(uri);
-
- httpPut.setHeaders(headers);
- httpPut.setEntity(body);
- SpotifyApi.LOGGER.log(
- Level.FINE,
- "PUT request uses these headers: " + GSON.toJson(headers));
-
- String responseBody = getResponseBody(execute(httpClient, httpPut));
-
- httpPut.reset();
-
- return responseBody;
- }
-
- @Override
- public String delete(URI uri, Header[] headers, HttpEntity body) throws
- IOException,
- SpotifyWebApiException,
- ParseException {
- assert (uri != null);
- assert (!uri.toString().equals(""));
-
- final HttpDelete httpDelete = new HttpDelete(uri);
-
- httpDelete.setHeaders(headers);
- httpDelete.setEntity(body);
- SpotifyApi.LOGGER.log(
- Level.FINE,
- "DELETE request uses these headers: " + GSON.toJson(headers));
-
- String responseBody = getResponseBody(execute(httpClient, httpDelete));
-
- httpDelete.reset();
-
- return responseBody;
- }
-
- private CloseableHttpResponse execute(CloseableHttpClient httpClient, ClassicHttpRequest method) throws
- IOException {
- HttpCacheContext context = HttpCacheContext.create();
- CloseableHttpResponse response = httpClient.execute(method, context);
-
- try {
- CacheResponseStatus responseStatus = context.getCacheResponseStatus();
-
- if (responseStatus != null) {
- switch (responseStatus) {
- case CACHE_HIT:
- SpotifyApi.LOGGER.log(
- Level.CONFIG,
- "A response was generated from the cache with no requests sent upstream");
- break;
- case CACHE_MODULE_RESPONSE:
- SpotifyApi.LOGGER.log(
- Level.CONFIG,
- "The response was generated directly by the caching module");
- break;
- case CACHE_MISS:
- SpotifyApi.LOGGER.log(
- Level.CONFIG,
- "The response came from an upstream server");
- break;
- case VALIDATED:
- SpotifyApi.LOGGER.log(
- Level.CONFIG,
- "The response was generated from the cache after validating the entry with the origin server");
- break;
- case FAILURE:
- SpotifyApi.LOGGER.log(
- Level.CONFIG,
- "The response came from an upstream server after a cache failure");
- break;
- }
- }
- } catch (Exception e) {
- SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage());
- }
-
- return response;
- }
-
- private String getResponseBody(CloseableHttpResponse httpResponse) throws
- IOException,
- SpotifyWebApiException,
- ParseException {
-
- final String responseBody = httpResponse.getEntity() != null
- ? EntityUtils.toString(httpResponse.getEntity(), "UTF-8")
- : null;
- String errorMessage = httpResponse.getReasonPhrase();
-
- SpotifyApi.LOGGER.log(
- Level.FINE,
- "The http response has body " + responseBody);
-
- if (responseBody != null && !responseBody.equals("")) {
- try {
- final JsonElement jsonElement = JsonParser.parseString(responseBody);
-
- if (jsonElement.isJsonObject()) {
- final JsonObject jsonObject = JsonParser.parseString(responseBody).getAsJsonObject();
-
- if (jsonObject.has("error")) {
- if (jsonObject.has("error_description")) {
- errorMessage = jsonObject.get("error_description").getAsString();
- } else if (jsonObject.get("error").isJsonObject() && jsonObject.getAsJsonObject("error").has("message")) {
- errorMessage = jsonObject.getAsJsonObject("error").get("message").getAsString();
- }
- }
- }
- } catch (JsonSyntaxException e) {
- // Not necessary
- }
- }
-
- SpotifyApi.LOGGER.log(
- Level.FINE,
- "The http response has status code " + httpResponse.getCode());
-
- switch (httpResponse.getCode()) {
- case HttpStatus.SC_BAD_REQUEST:
- throw new BadRequestException(errorMessage);
- case HttpStatus.SC_UNAUTHORIZED:
- throw new UnauthorizedException(errorMessage);
- case HttpStatus.SC_FORBIDDEN:
- throw new ForbiddenException(errorMessage);
- case HttpStatus.SC_NOT_FOUND:
- throw new NotFoundException(errorMessage);
- case 429: // TOO_MANY_REQUESTS (additional status code, RFC 6585)
- // Sets "Retry-After" header as described at https://beta.developer.spotify.com/documentation/web-api/#rate-limiting
- Header header = httpResponse.getFirstHeader("Retry-After");
-
- if (header != null) {
- throw new TooManyRequestsException(errorMessage, Integer.parseInt(header.getValue()));
- } else {
- throw new TooManyRequestsException(errorMessage);
- }
- case HttpStatus.SC_INTERNAL_SERVER_ERROR:
- throw new InternalServerErrorException(errorMessage);
- case HttpStatus.SC_BAD_GATEWAY:
- throw new BadGatewayException(errorMessage);
- case HttpStatus.SC_SERVICE_UNAVAILABLE:
- throw new ServiceUnavailableException(errorMessage);
- default:
- return responseBody;
- }
- }
-
- public static class Builder {
- private HttpHost proxy;
- private UsernamePasswordCredentials proxyCredentials;
- private Integer cacheMaxEntries;
- private Integer cacheMaxObjectSize;
- private Integer connectionRequestTimeout;
- private Integer connectTimeout;
- private Integer socketTimeout;
-
- public Builder setProxy(HttpHost proxy) {
- this.proxy = proxy;
- return this;
- }
-
- public Builder setProxyCredentials(UsernamePasswordCredentials proxyCredentials) {
- this.proxyCredentials = proxyCredentials;
- return this;
- }
-
- public Builder setCacheMaxEntries(Integer cacheMaxEntries) {
- this.cacheMaxEntries = cacheMaxEntries;
- return this;
- }
-
- public Builder setCacheMaxObjectSize(Integer cacheMaxObjectSize) {
- this.cacheMaxObjectSize = cacheMaxObjectSize;
- return this;
- }
-
- public Builder setConnectionRequestTimeout(Integer connectionRequestTimeout) {
- this.connectionRequestTimeout = connectionRequestTimeout;
- return this;
- }
-
- public Builder setConnectTimeout(Integer connectTimeout) {
- this.connectTimeout = connectTimeout;
- return this;
- }
-
- public Builder setSocketTimeout(Integer socketTimeout) {
- this.socketTimeout = socketTimeout;
- return this;
- }
-
- public SpotifyHttpManager build() {
- return new SpotifyHttpManager(this);
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/Action.java'
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible {@link Action} types.
- *
- * @see Disallows object
- */
-public enum Action {
-
- INTERRUPTING_PLAYBACK("interrupting_playback"),
- PAUSING("pausing"),
- RESUMING("resuming"),
- SEEKING("seeking"),
- SKIPPING_NEXT("skipping_next"),
- SKIPPING_PREV("skipping_prev"),
- TOGGLING_REPEAT_CONTEXT("toggling_repeat_context"),
- TOGGLING_SHUFFLE("toggling_shuffle"),
- TOGGLING_REPEAT_TRACK("toggling_repeat_track"),
- TRANSFERRING_PLAYBACK("transferring_playback");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (Action action : Action.values()) {
- map.put(action.key, action);
- }
- }
-
- public final String key;
-
- Action(final String key) {
- this.key = key;
- }
-
- public static Action keyOf(String key) {
- return map.get(key);
- }
-
- /**
- * Get the {@link Action} key as a string.
- *
- * @return {@link Action} key as string.
- */
- public String getKey() {
- return key;
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/AlbumGroup.java'
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible album types.
- */
-public enum AlbumGroup {
-
- ALBUM("album"),
- APPEARS_ON("appears_on"),
- COMPILATION("compilation"),
- SINGLE("single");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (AlbumGroup albumGroup : AlbumGroup.values()) {
- map.put(albumGroup.group, albumGroup);
- }
- }
-
- public final String group;
-
- AlbumGroup(final String group) {
- this.group = group;
- }
-
- public static AlbumGroup keyOf(String type) {
- return map.get(type);
- }
-
- /**
- * Get the album group as a string.
- *
- * @return Album group as string.
- */
- public String getGroup() {
- return group;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/AlbumType.java'
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible album types.
- */
-public enum AlbumType {
-
- ALBUM("album"),
- COMPILATION("compilation"),
- SINGLE("single");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (AlbumType albumType : AlbumType.values()) {
- map.put(albumType.type, albumType);
- }
- }
-
- public final String type;
-
- AlbumType(final String type) {
- this.type = type;
- }
-
- public static AlbumType keyOf(String type) {
- return map.get(type);
- }
-
- /**
- * Get the album type as a string.
- *
- * @return Album type as string.
- */
- public String getType() {
- return type;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/CopyrightType.java'
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import com.wrapper.spotify.model_objects.specification.Copyright;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible {@link Copyright} types.
- */
-public enum CopyrightType {
-
- C("c"),
- P("p");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (CopyrightType copyrightType : CopyrightType.values()) {
- map.put(copyrightType.type, copyrightType);
- }
- }
-
- public final String type;
-
- CopyrightType(final String type) {
- this.type = type;
- }
-
- public static CopyrightType keyOf(String type) {
- return map.get(type);
- }
-
- /**
- * Get the {@link Copyright} type as a string.
- *
- * @return {@link Copyright} type as string.
- */
- public String getType() {
- return type;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/CurrentlyPlayingType.java'
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible currently playing types.
- */
-public enum CurrentlyPlayingType {
-
- TRACK("track"),
- EPISODE("episode"),
- AD("ad"),
- UNKNOWN("unknown");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (CurrentlyPlayingType currentlyPlayingType : CurrentlyPlayingType.values()) {
- map.put(currentlyPlayingType.type, currentlyPlayingType);
- }
- }
-
-
- private final String type;
-
- CurrentlyPlayingType(final String type) {
- this.type = type;
- }
-
- public static CurrentlyPlayingType keyOf(String type) {
- return map.get(type);
- }
-
- /**
- * Get the currently playing type as a string.
- *
- * @return The currently playing type as a string.
- */
- public String getType() {
- return type;
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/Modality.java'
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration with the two modality types.
- *
- * @see Wikipedia: Mode (Music)
- */
-public enum Modality {
-
- MAJOR(1),
- MINOR(0);
-
- private static final Map map = new HashMap<>();
-
- static {
- for (Modality modality : Modality.values()) {
- map.put(modality.mode, modality);
- }
- }
-
- public final int mode;
-
- Modality(final int mode) {
- this.mode = mode;
- }
-
- public static Modality keyOf(int mode) {
- return map.get(mode);
- }
-
- /**
- * Get the {@link Modality} type as a string.
- *
- * @return {@link Modality} type as a string.
- */
- public int getType() {
- return this.mode;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/ModelObjectType.java'
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible model object types.
- */
-public enum ModelObjectType {
-
- ALBUM("album"),
- ARTIST("artist"),
- AUDIO_FEATURES("audio_features"),
- EPISODE("episode"),
- GENRE("genre"),
- PLAYLIST("playlist"),
- SHOW("show"),
- TRACK("track"),
- USER("user");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (ModelObjectType modelObjectType : ModelObjectType.values()) {
- map.put(modelObjectType.type, modelObjectType);
- }
- }
-
- public final String type;
-
- ModelObjectType(final String type) {
- this.type = type;
- }
-
- public static ModelObjectType keyOf(String type) {
- return map.get(type);
- }
-
- /**
- * Get the model object type as a string.
- *
- * @return The model object type as a string.
- */
- public String getType() {
- return this.type;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/ProductType.java'
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible Spotify product types.
- */
-public enum ProductType {
-
- BASIC_DESKTOP("basic-desktop"),
- DAYPASS("daypass"),
- FREE("free"),
- OPEN("open"),
- PREMIUM("premium");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (ProductType productType : ProductType.values()) {
- map.put(productType.type, productType);
- }
- }
-
- public final String type;
-
- ProductType(final String type) {
- this.type = type;
- }
-
- public static ProductType keyOf(String type) {
- return map.get(type);
- }
-
- /**
- * Get the Spotify product type as a string.
- *
- * @return The Spotify product type as a string.
- */
- public String getType() {
- return type;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/enums/ReleaseDatePrecision.java'
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.wrapper.spotify.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An enumeration of all possible release date precisions.
- */
-public enum ReleaseDatePrecision {
-
- DAY("day"),
- MONTH("month"),
- YEAR("year");
-
- private static final Map map = new HashMap<>();
-
- static {
- for (ReleaseDatePrecision releaseDatePrecision : ReleaseDatePrecision.values()) {
- map.put(releaseDatePrecision.precision, releaseDatePrecision);
- }
- }
-
- public final String precision;
-
- ReleaseDatePrecision(final String precision) {
- this.precision = precision;
- }
-
- public static ReleaseDatePrecision keyOf(String precision) {
- return map.get(precision);
- }
-
- /**
- * Get the release date precision as a string.
- *
- * @return The release date precision as a string.
- */
- public String getPrecision() {
- return precision;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/SpotifyWebApiException.java'
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.wrapper.spotify.exceptions;
-
-import org.apache.hc.core5.http.HttpException;
-
-/**
- * An exception happened, eg. a HTTP status code 4** or 5** has been returned in a request.
- */
-public class SpotifyWebApiException extends HttpException {
-
- public SpotifyWebApiException() {
- super();
- }
-
- public SpotifyWebApiException(String message) {
- super(message);
- }
-
- public SpotifyWebApiException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/BadGatewayException.java'
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
- */
-public class BadGatewayException extends SpotifyWebApiException {
-
- public BadGatewayException() {
- super();
- }
-
- public BadGatewayException(String message) {
- super(message);
- }
-
- public BadGatewayException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/BadRequestException.java'
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * The request could not be understood by the server due to malformed syntax.
- */
-public class BadRequestException extends SpotifyWebApiException {
-
- public BadRequestException() {
- super();
- }
-
- public BadRequestException(String message) {
- super(message);
- }
-
- public BadRequestException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/ForbiddenException.java'
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * The server understood the request, but is refusing to fulfill it.
- */
-public class ForbiddenException extends SpotifyWebApiException {
-
- public ForbiddenException() {
- super();
- }
-
- public ForbiddenException(String message) {
- super(message);
- }
-
- public ForbiddenException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/InternalServerErrorException.java'
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * You should never receive this error because our clever coders catch them all ... but if you are unlucky enough to get
- * one, please report it to us.
- */
-public class InternalServerErrorException extends SpotifyWebApiException {
-
- public InternalServerErrorException() {
- super();
- }
-
- public InternalServerErrorException(String message) {
- super(message);
- }
-
- public InternalServerErrorException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/NotFoundException.java'
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * The requested resource could not be found. This error can be due to a temporary or permanent condition.
- */
-public class NotFoundException extends SpotifyWebApiException {
-
- public NotFoundException() {
- super();
- }
-
- public NotFoundException(String message) {
- super(message);
- }
-
- public NotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/ServiceUnavailableException.java'
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * The server is currently unable to handle the request due to a temporary condition which will be alleviated after some
- * delay. You can choose to resend the request again.
- */
-public class ServiceUnavailableException extends SpotifyWebApiException {
-
- public ServiceUnavailableException() {
- super();
- }
-
- public ServiceUnavailableException(String message) {
- super(message);
- }
-
- public ServiceUnavailableException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/TooManyRequestsException.java'
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * Rate limiting has been applied.
- */
-public class TooManyRequestsException extends SpotifyWebApiException {
-
- private int retryAfter;
-
- public TooManyRequestsException() {
- super();
- }
-
- public TooManyRequestsException(String message, int retryAfter) {
- super(message);
- this.setRetryAfter(retryAfter);
- }
-
- public TooManyRequestsException(String message) {
- super(message);
- }
-
- public TooManyRequestsException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public int getRetryAfter() {
- return retryAfter;
- }
-
- public void setRetryAfter(int retryAfter) {
- this.retryAfter = retryAfter;
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/exceptions/detailed/UnauthorizedException.java'
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.wrapper.spotify.exceptions.detailed;
-
-import com.wrapper.spotify.exceptions.SpotifyWebApiException;
-
-/**
- * The request requires user authorization or, if the request included authorization credentials, authorization has been
- * refused for those credentials.
- */
-public class UnauthorizedException extends SpotifyWebApiException {
-
- public UnauthorizedException() {
- super();
- }
-
- public UnauthorizedException(String message) {
- super(message);
- }
-
- public UnauthorizedException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/AbstractModelObject.java'
+++ /dev/null
@@ -1,211 +0,0 @@
-package com.wrapper.spotify.model_objects;
-
-import com.google.gson.*;
-import com.wrapper.spotify.model_objects.specification.Cursor;
-import com.wrapper.spotify.model_objects.specification.Paging;
-import com.wrapper.spotify.model_objects.specification.PagingCursorbased;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.ParameterizedType;
-
-/**
- * This abstract class (and its wrapping classes) is used as a sort of template for other model object classes and
- * includes multiple generic methods.
- */
-public abstract class AbstractModelObject implements IModelObject {
-
- /**
- * This constructor initializes the time zone.
- *
- * @param builder The builder object of the corresponding model object.
- */
- protected AbstractModelObject(final Builder builder) {
- assert (builder != null);
- }
-
- /**
- * Returns a String representation of this model object in the style:
- * {@code ModelObject(attr1=value1, attr2=value2, ...)}
- */
- @Override
- public abstract String toString(); // abstract enforces overriding of toString() for subclasses
-
- /**
- * Each model object needs to implement its own builder class.
- */
- public static abstract class Builder implements IModelObject.Builder {
- }
-
- /**
- * Each model object needs to implement its own JsonUtil class.
- *
- * @param The model object type of the corresponding JsonUtil.
- */
- public static abstract class JsonUtil implements IModelObject.IJsonUtil {
-
- /**
- * {@inheritDoc}
- */
- public boolean hasAndNotNull(final JsonObject jsonObject, final String memberName) {
- return jsonObject.has(memberName) && !jsonObject.get(memberName).isJsonNull();
- }
-
- /**
- * {@inheritDoc}
- */
- public T createModelObject(final String json) {
- if (json == null) {
- return null;
- } else {
- return createModelObject(JsonParser.parseString(json).getAsJsonObject());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public T[] createModelObjectArray(final JsonArray jsonArray) {
- @SuppressWarnings("unchecked")
- T[] array = (T[]) Array.newInstance((Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0], jsonArray.size());
-
- for (int i = 0; i < jsonArray.size(); i++) {
- JsonElement jsonElement = jsonArray.get(i);
-
- if (jsonElement instanceof JsonNull) {
- array[i] = null;
- } else {
- JsonObject jsonObject = jsonElement.getAsJsonObject();
- array[i] = createModelObject(jsonObject);
- }
- }
-
- return array;
- }
-
- /**
- * {@inheritDoc}
- */
- public T[] createModelObjectArray(final String json) {
- return createModelObjectArray(JsonParser.parseString(json).getAsJsonArray());
- }
-
- /**
- * {@inheritDoc}
- */
- public T[] createModelObjectArray(final String json, final String key) {
- return createModelObjectArray(JsonParser.parseString(json).getAsJsonObject().get(key).getAsJsonArray());
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- public X[] createModelObjectArray(final JsonArray jsonArray, Class clazz) {
- X[] array = (X[]) Array.newInstance(clazz, jsonArray.size());
-
- for (int i = 0; i < jsonArray.size(); i++) {
- JsonElement jsonElement = jsonArray.get(i);
- JsonObject jsonObject = jsonElement.getAsJsonObject();
- array[i] = (X) createModelObject(jsonObject);
- }
-
- return array;
- }
-
- /**
- * {@inheritDoc}
- */
- public Paging createModelObjectPaging(final JsonObject jsonObject) {
- return new Paging.Builder()
- .setHref(
- hasAndNotNull(jsonObject, "href")
- ? jsonObject.get("href").getAsString()
- : null)
- .setItems(
- hasAndNotNull(jsonObject, "items")
- ? createModelObjectArray(jsonObject.getAsJsonArray("items"))
- : null)
- .setLimit(
- hasAndNotNull(jsonObject, "limit")
- ? jsonObject.get("limit").getAsInt()
- : null)
- .setNext(
- hasAndNotNull(jsonObject, "next")
- ? jsonObject.get("next").getAsString()
- : null)
- .setOffset(
- hasAndNotNull(jsonObject, "offset")
- ? jsonObject.get("offset").getAsInt()
- : null)
- .setPrevious(
- hasAndNotNull(jsonObject, "previous")
- ? jsonObject.get("previous").getAsString()
- : null)
- .setTotal(
- hasAndNotNull(jsonObject, "total")
- ? jsonObject.get("total").getAsInt()
- : null)
- .build();
- }
-
- /**
- * {@inheritDoc}
- */
- public Paging createModelObjectPaging(final String json) {
- return createModelObjectPaging(JsonParser.parseString(json).getAsJsonObject());
- }
-
- /**
- * {@inheritDoc}
- */
- public Paging createModelObjectPaging(final String json, final String key) {
- return createModelObjectPaging(JsonParser.parseString(json).getAsJsonObject().get(key).getAsJsonObject());
- }
-
- /**
- * {@inheritDoc}
- */
- public PagingCursorbased createModelObjectPagingCursorbased(final JsonObject jsonObject) {
- return new PagingCursorbased.Builder()
- .setHref(
- hasAndNotNull(jsonObject, "href")
- ? jsonObject.get("href").getAsString()
- : null)
- .setItems(
- hasAndNotNull(jsonObject, "items")
- ? createModelObjectArray(jsonObject.getAsJsonArray("items"))
- : null)
- .setLimit(
- hasAndNotNull(jsonObject, "limit")
- ? jsonObject.get("limit").getAsInt()
- : null)
- .setNext(
- hasAndNotNull(jsonObject, "next")
- ? jsonObject.get("next").getAsString()
- : null)
- .setCursors(
- hasAndNotNull(jsonObject, "cursors")
- ? new Cursor.JsonUtil().createModelObject(jsonObject.getAsJsonObject("cursors"))
- : null)
- .setTotal(
- hasAndNotNull(jsonObject, "total")
- ? jsonObject.get("total").getAsInt()
- : null)
- .build();
- }
-
- /**
- * {@inheritDoc}
- */
- public PagingCursorbased createModelObjectPagingCursorbased(final String json) {
- return createModelObjectPagingCursorbased(JsonParser.parseString(json).getAsJsonObject());
- }
-
- /**
- * {@inheritDoc}
- */
- public PagingCursorbased createModelObjectPagingCursorbased(final String json, final String key) {
- return createModelObjectPagingCursorbased(JsonParser.parseString(json).getAsJsonObject().get(key).getAsJsonObject());
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/IModelObject.java'
+++ /dev/null
@@ -1,158 +0,0 @@
-package com.wrapper.spotify.model_objects;
-
-import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.specification.Paging;
-import com.wrapper.spotify.model_objects.specification.PagingCursorbased;
-
-import java.io.Serializable;
-
-/**
- * Interface with methods used in model objects.
- */
-public interface IModelObject extends Serializable {
-
- /**
- * Create a builder for building an instance of a model object.
- * The type of the builder and its methods depend on its corresponding implementation.
- *
- * @return A builder object.
- */
- Builder builder();
-
- /**
- * Interface with methods used in builder classes of model objects.
- */
- @JsonPOJOBuilder(withPrefix = "set")
- interface Builder {
-
- /**
- * Build a model object with the information set in the builder object.
- * The type of the model object and its methods depend on its corresponding implementation.
- *
- * @return A model object.
- */
- IModelObject build();
- }
-
- /**
- * Interface with methods used in JsonUtil classes of model objects.
- *
- * @param Type of the corresponding model object.
- */
- interface IJsonUtil {
-
- /**
- * Check whether the supplied JSON object contains data in the given member, which is not {@code null}.
- *
- * @param jsonObject The JSON object.
- * @param memberName The member name.
- * @return Whether the supplied JSON object contains data in the given member.
- */
- boolean hasAndNotNull(final JsonObject jsonObject, final String memberName);
-
- /**
- * Build a model object with the information given in a json object.
- * The type of the model object and its methods depend on its corresponding implementation.
- *
- * @param jsonObject A json object.
- * @return A model object. The type depends on this methods implementation.
- */
- T createModelObject(final JsonObject jsonObject);
-
- /**
- * Build a model object with the information given in a json string.
- * The type of the model object and its methods depend on its corresponding implementation.
- *
- * @param json A json object.
- * @return A model object. The type depends on this methods implementation.
- */
- T createModelObject(final String json);
-
- /**
- * Create an array of model objects out of a json array object.
- *
- * @param jsonArray A {@link JsonArray}.
- * @return A model object array. The type depends on this methods implementation.
- */
- T[] createModelObjectArray(final JsonArray jsonArray);
-
- /**
- * Create an array of model objects out of a json string.
- *
- * @param json A {@link JsonArray}.
- * @return A model object array. The type depends on this methods implementation.
- */
- T[] createModelObjectArray(final String json);
-
- /**
- * Create an array of model objects out of a json array, which is contained in a json object.
- *
- * @param json A {@link JsonObject}.
- * @param key The key of the json array in the json object.
- * @return A model object array. The type depends on this methods implementation.
- */
- T[] createModelObjectArray(final String json, final String key);
-
- /**
- * Create an array of model objects out of a json array object and a {@link Class} object.
- *
- * @param jsonArray A json array object.
- * @param clazz The class object.
- * @param The model object type of the array and class object.
- * @return A model object array.
- */
- X[] createModelObjectArray(final JsonArray jsonArray, final Class clazz);
-
- /**
- * Create a paging of model objects out of a json object.
- *
- * @param jsonObject A json object.
- * @return A model object paging.
- */
- Paging createModelObjectPaging(final JsonObject jsonObject);
-
- /**
- * Create a paging of model objects out of a json string.
- *
- * @param json A json string.
- * @return A model object paging.
- */
- Paging createModelObjectPaging(final String json);
-
- /**
- * Create a paging of model objects out of a json array, which is contained in a json object.
- *
- * @param json A {@link JsonObject}.
- * @param key The key of the json array in the json object.
- * @return A model object array. The type depends on this methods implementation.
- */
- Paging createModelObjectPaging(final String json, final String key);
-
- /**
- * Create a cursor-based paging of model objects out of a json object.
- *
- * @param jsonObject A json object.
- * @return A cursor-based model object paging.
- */
- PagingCursorbased createModelObjectPagingCursorbased(final JsonObject jsonObject);
-
- /**
- * Create a cursor-based paging of model objects out of a json string.
- *
- * @param json A json string.
- * @return A cursor-based model object paging.
- */
- PagingCursorbased createModelObjectPagingCursorbased(final String json);
-
- /**
- * Create a cursor-based paging of model objects out of a json array, which is contained in a json object.
- *
- * @param json A {@link JsonObject}.
- * @param key The key of the json array in the json object.
- * @return A cursor-based model object paging.
- */
- PagingCursorbased createModelObjectPagingCursorbased(final String json, final String key);
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/IPlaylistItem.java'
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.wrapper.spotify.model_objects;
-
-import com.wrapper.spotify.enums.ModelObjectType;
-import com.wrapper.spotify.model_objects.specification.Episode;
-import com.wrapper.spotify.model_objects.specification.ExternalUrl;
-import com.wrapper.spotify.model_objects.specification.Track;
-
-
-/**
- * This interface represents objects returned by the API that can be played, saved in a playlist, etc,
- * currently {@link Episode} and {@link Track}.
- */
-public interface IPlaylistItem extends IModelObject {
-
- /**
- * Get the duration of this playlist item in milliseconds.
- *
- * @return The playlist item length in milliseconds.
- */
- public Integer getDurationMs();
-
- /**
- * Get the external URLs of the playlist item.
- * Example: Spotify-URL.
- *
- * @return Known external URLs for this playlist item.
- */
- public ExternalUrl getExternalUrls();
-
- /**
- * Get the full Spotify Web API endpoint URL of the playlist item.
- *
- * @return A link to the Web API endpoint providing full details of the playlist item.
- */
- public String getHref();
-
- /**
- * Get the Spotify ID of the
- * playlist item.
- *
- * @return The Spotify ID for the playlist item.
- */
- public String getId();
-
- /**
- * Get the name of the playlist item.
- *
- * @return playlist item name.
- */
- public String getName();
-
- /**
- * Get the type of the IPlaylistItem.
- * Possible values: {@code ModelObjectType.TRACK} or {@code ModelObjectType.EPISODE}
- *
- * @return The type of the IPlaylistItem.
- */
- ModelObjectType getType();
-
- /**
- * Get the Spotify playlist item URI.
- *
- * @return The Spotify URI for
- * the playlist item.
- */
- public String getUri();
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/credentials/AuthorizationCodeCredentials.java'
+++ /dev/null
@@ -1,194 +0,0 @@
-package com.wrapper.spotify.model_objects.credentials;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about
- * Authorization Code
- * Credentials by building instances from this class.
- */
-@JsonDeserialize(builder = AuthorizationCodeCredentials.Builder.class)
-public class AuthorizationCodeCredentials extends AbstractModelObject {
- private final String accessToken;
- private final String tokenType;
- private final String scope;
- private final Integer expiresIn;
- private final String refreshToken;
-
- private AuthorizationCodeCredentials(final Builder builder) {
- super(builder);
-
- this.accessToken = builder.accessToken;
- this.tokenType = builder.tokenType;
- this.scope = builder.scope;
- this.expiresIn = builder.expiresIn;
- this.refreshToken = builder.refreshToken;
- }
-
- /**
- * Get the access token. It becomes invalid after a certain period of time.
- *
- * @return An access token that can be provided in subsequent calls, for example to Spotify Web API services.
- */
- public String getAccessToken() {
- return accessToken;
- }
-
- /**
- * Get the type of an access token, which will always be "Bearer".
- *
- * @return How the access token may be used: always "Bearer".
- */
- public String getTokenType() {
- return tokenType;
- }
-
-
- /**
- * Get the Scopes specified in the authorization
- * code credentials request.
- *
- * @return The scopes specified in the credentials request.
- */
- public String getScope() {
- return scope;
- }
-
- /**
- * Get the time period (in seconds) for which the access token is valid.
- *
- * @return The time period (in seconds) for which the access token is valid.
- */
- public Integer getExpiresIn() {
- return expiresIn;
- }
-
- /**
- * Get the refresh token. This token can be sent to the Spotify Accounts service in place of an authorization code to
- * retrieve a new access token.
- *
- * @return A token that can be sent to the Spotify Accounts service in place of an access token.
- */
- public String getRefreshToken() {
- return refreshToken;
- }
-
- @Override
- public String toString() {
- return "AuthorizationCodeCredentials(accessToken=" + accessToken + ", tokenType=" + tokenType + ", scope=" + scope
- + ", expiresIn=" + expiresIn + ", refreshToken=" + refreshToken + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AuthorizationCodeCredentials} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String accessToken;
- private String tokenType;
- private String scope;
- private Integer expiresIn;
- private String refreshToken;
-
- /**
- * The access token setter.
- *
- * @param accessToken An access token that can be provided in subsequent calls,
- * for example to Spotify Web API services.
- * @return An {@link AuthorizationCodeCredentials.Builder}.
- */
- public Builder setAccessToken(final String accessToken) {
- this.accessToken = accessToken;
- return this;
- }
-
- /**
- * The access token type setter.
- *
- * @param tokenType How the access token may be used: always "Bearer".
- * @return An {@link AuthorizationCodeCredentials.Builder}.
- */
- public Builder setTokenType(final String tokenType) {
- this.tokenType = tokenType;
- return this;
- }
-
- /**
- * The scopes setter.
- *
- * @param scope The scopes specified in the credentials request.
- * @return An {@link AuthorizationCodeCredentials.Builder}.
- */
- public Builder setScope(final String scope) {
- this.scope = scope;
- return this;
- }
-
- /**
- * The expiration time setter.
- *
- * @param expiresIn The time period (in seconds) for which the access token is valid.
- * @return An {@link AuthorizationCodeCredentials.Builder}.
- */
- public Builder setExpiresIn(final Integer expiresIn) {
- this.expiresIn = expiresIn;
- return this;
- }
-
- /**
- * The refresh token setter.
- *
- * @param refreshToken A token that can be sent to the Spotify Accounts service in place of an authorization code.
- * @return An {@link AuthorizationCodeCredentials.Builder}.
- */
- public Builder setRefreshToken(final String refreshToken) {
- this.refreshToken = refreshToken;
- return this;
- }
-
- @Override
- public AuthorizationCodeCredentials build() {
- return new AuthorizationCodeCredentials(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AuthorizationCodeCredentials} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AuthorizationCodeCredentials createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AuthorizationCodeCredentials.Builder()
- .setAccessToken(
- hasAndNotNull(jsonObject, "access_token")
- ? jsonObject.get("access_token").getAsString()
- : null)
- .setTokenType(
- hasAndNotNull(jsonObject, "token_type")
- ? jsonObject.get("token_type").getAsString()
- : null)
- .setScope(
- hasAndNotNull(jsonObject, "scope")
- ? jsonObject.get("scope").getAsString()
- : null)
- .setExpiresIn(
- hasAndNotNull(jsonObject, "expires_in")
- ? jsonObject.get("expires_in").getAsInt()
- : null)
- .setRefreshToken(
- hasAndNotNull(jsonObject, "refresh_token")
- ? jsonObject.get("refresh_token").getAsString()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/credentials/ClientCredentials.java'
+++ /dev/null
@@ -1,136 +0,0 @@
-package com.wrapper.spotify.model_objects.credentials;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about
- * Client Credentials by building instances from this class.
- */
-@JsonDeserialize(builder = ClientCredentials.Builder.class)
-public class ClientCredentials extends AbstractModelObject {
- private final String accessToken;
- private final String tokenType;
- private final Integer expiresIn;
-
- private ClientCredentials(final Builder builder) {
- super(builder);
-
- this.accessToken = builder.accessToken;
- this.tokenType = builder.tokenType;
- this.expiresIn = builder.expiresIn;
- }
-
- /**
- * Get the access token. It becomes invalid after a certain period of time.
- *
- * @return An access token that can be provided in subsequent calls, for example to Spotify Web API services.
- */
- public String getAccessToken() {
- return accessToken;
- }
-
- /**
- * Get the type of an access token, which will always be "Bearer".
- *
- * @return How the access token may be used: always "Bearer".
- */
- public String getTokenType() {
- return tokenType;
- }
-
- /**
- * Get the time period (in seconds) for which the access token is valid.
- *
- * @return The time period (in seconds) for which the access token is valid.
- */
- public Integer getExpiresIn() {
- return expiresIn;
- }
-
- @Override
- public String toString() {
- return "ClientCredentials(accessToken=" + accessToken + ", tokenType=" + tokenType + ", expiresIn=" + expiresIn
- + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link ClientCredentials} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String accessToken;
- private String tokenType;
- private Integer expiresIn;
-
- /**
- * The access token setter.
- *
- * @param accessToken An access token that can be provided in subsequent calls,
- * for example to Spotify Web API services.
- * @return A {@link ClientCredentials.Builder}.
- */
- public Builder setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- return this;
- }
-
- /**
- * The access token type setter.
- *
- * @param tokenType How the access token may be used: always "Bearer".
- * @return A {@link ClientCredentials.Builder}.
- */
- public Builder setTokenType(String tokenType) {
- this.tokenType = tokenType;
- return this;
- }
-
- /**
- * The expiration time setter.
- *
- * @param expiresIn The time period (in seconds) for which the access token is valid.
- * @return A {@link ClientCredentials.Builder}.
- */
- public Builder setExpiresIn(Integer expiresIn) {
- this.expiresIn = expiresIn;
- return this;
- }
-
- @Override
- public ClientCredentials build() {
- return new ClientCredentials(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link ClientCredentials} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public ClientCredentials createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new ClientCredentials.Builder()
- .setAccessToken(
- hasAndNotNull(jsonObject, "access_token")
- ? jsonObject.get("access_token").getAsString()
- : null)
- .setTokenType(
- hasAndNotNull(jsonObject, "token_type")
- ? jsonObject.get("token_type").getAsString()
- : null)
- .setExpiresIn(
- hasAndNotNull(jsonObject, "expires_in")
- ? jsonObject.get("expires_in").getAsInt()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/credentials/error/AuthenticationError.java'
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.wrapper.spotify.model_objects.credentials.error;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Authorization Error objects by building instances from this class.
- *
- * @see Spotify: Authorization Guide
- */
-@JsonDeserialize(builder = AuthenticationError.Builder.class)
-public class AuthenticationError extends AbstractModelObject {
- private final String error;
- private final String error_description;
-
- private AuthenticationError(final Builder builder) {
- super(builder);
-
- this.error = builder.error;
- this.error_description = builder.error_description;
- }
-
- /**
- * Get the high level description of the error as specified in
- * RFC 6749 Section 5.2.
- *
- * @return A high level description of the error as specified in RFC 6749 Section 5.2.
- */
- public String getError() {
- return error;
- }
-
- /**
- * Get the more detailed description of the error as specified in
- * RFC 6749 Section 4.1.2.1.
- *
- * @return string A more detailed description of the error as specified in RFC 6749 Section 4.1.2.1.
- */
- public String getError_description() {
- return error_description;
- }
-
- @Override
- public String toString() {
- return "AuthenticationError(error=" + error + ", error_description=" + error_description + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AuthenticationError} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String error;
- private String error_description;
-
- /**
- * The error setter.
- *
- * @param error A high level description of the error as specified in RFC 6749 Section 5.2.
- * @return An {@link AuthenticationError.Builder}.
- */
- public Builder setError(String error) {
- this.error = error;
- return this;
- }
-
- /**
- * The error description setter.
- *
- * @param error_description A more detailed description of the error as specified in RFC 6749 Section 4.1.2.1.
- * @return An {@link AuthenticationError.Builder}.
- */
- public Builder setError_description(String error_description) {
- this.error_description = error_description;
- return this;
- }
-
- @Override
- public AuthenticationError build() {
- return new AuthenticationError(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AuthenticationError} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AuthenticationError createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AuthenticationError.Builder()
- .setError(
- hasAndNotNull(jsonObject, "error")
- ? jsonObject.get("error").getAsString()
- : null)
- .setError_description(
- hasAndNotNull(jsonObject, "error_description")
- ? jsonObject.get("error_description").getAsString()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/AudioAnalysis.java'
+++ /dev/null
@@ -1,268 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about
- * Audio Analysis objects by building instances from this class.
- * These objects contain a great amount of additional information to
- * {@link com.wrapper.spotify.model_objects.specification.AudioFeatures} objects.
- *
- * Note: Audio Analysis data is created by the Software "Analyzer" by "The Echo Nest", which has been bought by
- * Spotify in the past. Since then, new Analyzer versions were created by Spotify but there is a lack of documentation
- * on the side of Spotify, so it is possible that this Javadoc page (and other Audio Analysis related Javadoc pages)
- * contains speculative information about a few of its corresponding methods.
- */
-@JsonDeserialize(builder = AudioAnalysis.Builder.class)
-public class AudioAnalysis extends AbstractModelObject {
- private final AudioAnalysisMeasure[] bars;
- private final AudioAnalysisMeasure[] beats;
- private final AudioAnalysisMeta meta;
- private final AudioAnalysisSection[] sections;
- private final AudioAnalysisSegment[] segments;
- private final AudioAnalysisMeasure[] tatums;
- private final AudioAnalysisTrack track;
-
- private AudioAnalysis(final Builder builder) {
- super(builder);
-
- this.bars = builder.bars;
- this.beats = builder.beats;
- this.meta = builder.meta;
- this.sections = builder.sections;
- this.segments = builder.segments;
- this.tatums = builder.tatums;
- this.track = builder.track;
- }
-
- /**
- * Get the list of bar markers, in seconds. A bar (or measure) is a segment of time defined as a given number of
- * beats. Bar offsets also indicate downbeats, the first beat of the measure.
- *
- * @return The list of bar markers, in seconds.
- */
- public AudioAnalysisMeasure[] getBars() {
- return bars;
- }
-
- /**
- * Get the list of beat markers, in seconds. A beat is the basic time unit of a piece of music; for example, each tick
- * of a metronome. Beats are typically multiples of tatums.
- *
- * @return The list of beat markers, in seconds.
- */
- public AudioAnalysisMeasure[] getBeats() {
- return beats;
- }
-
- /**
- * Get the metadata of the analyzer software for the track.
- *
- * @return Analyze, compute, and track information.
- */
- public AudioAnalysisMeta getMeta() {
- return meta;
- }
-
- /**
- * Get the set of section markers, in seconds. Sections are defined by large variations in rhythm or timbre, e.g.
- * chorus, verse, bridge, guitar solo, etc. Each section contains its own descriptions of tempo, key, mode,
- * time_signature, and loudness
- *
- * @return The set of section markers, in seconds.
- */
- public AudioAnalysisSection[] getSections() {
- return sections;
- }
-
- /**
- * Get the set of sound entities (typically under a second) each relatively uniform in timbre and harmony.
- * Segments are characterized by their perceptual onsets and duration in seconds, loudness (dB), pitch and timbral
- * content.
- *
- * @return The set of sound entities (typically under a second) each relatively uniform in timbre and harmony.
- */
- public AudioAnalysisSegment[] getSegments() {
- return segments;
- }
-
- /**
- * Get the list of tatum markers, in seconds. Tatums represent the lowest regular pulse train that a listener
- * intuitively infers from the timing of perceived musical events (segments).
- *
- * @return Get the list of tatum markers, in seconds.
- */
- public AudioAnalysisMeasure[] getTatums() {
- return tatums;
- }
-
- /**
- * Get the track data of the audio analysis object.
- *
- * @return Track data of audio analysis object.
- */
- public AudioAnalysisTrack getTrack() {
- return track;
- }
-
- @Override
- public String toString() {
- return "AudioAnalysis(bars=" + Arrays.toString(bars) + ", beats=" + Arrays.toString(beats) + ", meta=" + meta
- + ", sections=" + Arrays.toString(sections) + ", segments=" + Arrays.toString(segments) + ", tatums="
- + Arrays.toString(tatums) + ", track=" + track + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AudioAnalysis} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private AudioAnalysisMeasure[] bars;
- private AudioAnalysisMeasure[] beats;
- private AudioAnalysisMeta meta;
- private AudioAnalysisSection[] sections;
- private AudioAnalysisSegment[] segments;
- private AudioAnalysisMeasure[] tatums;
- private AudioAnalysisTrack track;
-
- /**
- * Track bars setter.
- *
- * @param bars The list of bar markers, in seconds.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setBars(AudioAnalysisMeasure[] bars) {
- this.bars = bars;
- return this;
- }
-
- /**
- * The track beats setter.
- *
- * @param beats The list of beat markers, in seconds.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setBeats(AudioAnalysisMeasure[] beats) {
- this.beats = beats;
- return this;
- }
-
- /**
- * The anaylzer metadata setter.
- *
- * @param meta Analyze, compute, and track information.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setMeta(AudioAnalysisMeta meta) {
- this.meta = meta;
- return this;
- }
-
- /**
- * The track sections setter.
- *
- * @param sections The set of section markers, in seconds.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setSections(AudioAnalysisSection[] sections) {
- this.sections = sections;
- return this;
- }
-
- /**
- * The track segments setter.
- *
- * @param segments The set of sound entities (typically under a second) each relatively uniform in timbre and
- * harmony.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setSegments(AudioAnalysisSegment[] segments) {
- this.segments = segments;
- return this;
- }
-
- /**
- * The track tatums setter.
- *
- * @param tatums Get the list of tatum markers, in seconds.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setTatums(AudioAnalysisMeasure[] tatums) {
- this.tatums = tatums;
- return this;
- }
-
- /**
- * The track data setter.
- *
- * @param track Track data of audio analysis object.
- * @return An {@link AudioAnalysis.Builder}.
- */
- public Builder setTrack(AudioAnalysisTrack track) {
- this.track = track;
- return this;
- }
-
- @Override
- public AudioAnalysis build() {
- return new AudioAnalysis(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AudioAnalysis} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AudioAnalysis createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AudioAnalysis.Builder()
- .setBars(
- hasAndNotNull(jsonObject, "bars")
- ? new AudioAnalysisMeasure.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("bars"))
- : null)
- .setBeats(
- hasAndNotNull(jsonObject, "beats")
- ? new AudioAnalysisMeasure.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("beats"))
- : null)
- .setMeta(
- hasAndNotNull(jsonObject, "meta")
- ? new AudioAnalysisMeta.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("meta"))
- : null)
- .setSections(
- hasAndNotNull(jsonObject, "sections")
- ? new AudioAnalysisSection.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("sections"))
- : null)
- .setSegments(
- hasAndNotNull(jsonObject, "segments")
- ? new AudioAnalysisSegment.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("segments"))
- : null)
- .setTatums(
- hasAndNotNull(jsonObject, "tatums")
- ? new AudioAnalysisMeasure.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("tatums"))
- : null)
- .setTrack(
- hasAndNotNull(jsonObject, "track")
- ? new AudioAnalysisTrack.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("track"))
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/AudioAnalysisMeasure.java'
+++ /dev/null
@@ -1,138 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Audio Analysis Measure objects by building instances from this class.
- * These objects can store the data of various {@link AudioAnalysis} measurements, like {@code tatums}, {@code bars} and
- * {@code beats}.
- */
-@JsonDeserialize(builder = AudioAnalysisMeasure.Builder.class)
-public class AudioAnalysisMeasure extends AbstractModelObject {
- private final Float confidence;
- private final Float duration;
- private final Float start;
-
- private AudioAnalysisMeasure(final Builder builder) {
- super(builder);
-
- this.confidence = builder.confidence;
- this.duration = builder.duration;
- this.start = builder.start;
- }
-
- /**
- * Get the confidence value of the measurement.
- * The confidence indicates the reliability of its corresponding attribute. Elements carrying a small confidence value
- * should be considered speculative.
- *
- * @return The confidence value of the measurement between 0.0 and 1.0.
- */
- public Float getConfidence() {
- return confidence;
- }
-
- /**
- * Get the duration of the measurement in seconds.
- * Example: Get the duration of a bar.
- *
- * @return The duration of the measurement in seconds.
- */
- public Float getDuration() {
- return duration;
- }
-
- /**
- * Get the start point of the measurement, eg. when the measured part of the track begins.
- *
- * @return The start point of the measurement.
- */
- public Float getStart() {
- return start;
- }
-
- @Override
- public String toString() {
- return "AudioAnalysisMeasure(confidence=" + confidence + ", duration=" + duration + ", start=" + start + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AudioAnalysisMeasure} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private Float confidence;
- private Float duration;
- private Float start;
-
- /**
- * The confidence setter.
- *
- * @param confidence The confidence value of the measurement between 0.0 and 1.0.
- * @return An {@link AudioAnalysisMeasure.Builder}.
- */
- public Builder setConfidence(Float confidence) {
- this.confidence = confidence;
- return this;
- }
-
- /**
- * The duration setter.
- *
- * @param duration The duration of the measurement in seconds.
- * @return An {@link AudioAnalysisMeasure.Builder}.
- */
- public Builder setDuration(Float duration) {
- this.duration = duration;
- return this;
- }
-
- /**
- * The start point setter.
- *
- * @param start The start point of the measurement.
- * @return An {@link AudioAnalysisMeasure.Builder}.
- */
- public Builder setStart(Float start) {
- this.start = start;
- return this;
- }
-
- @Override
- public AudioAnalysisMeasure build() {
- return new AudioAnalysisMeasure(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AudioAnalysisMeasure} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AudioAnalysisMeasure createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AudioAnalysisMeasure.Builder()
- .setConfidence(
- hasAndNotNull(jsonObject, "confidence")
- ? jsonObject.get("confidence").getAsFloat()
- : null)
- .setDuration(
- hasAndNotNull(jsonObject, "duration")
- ? jsonObject.get("duration").getAsFloat()
- : null)
- .setStart(
- hasAndNotNull(jsonObject, "start")
- ? jsonObject.get("start").getAsFloat()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/AudioAnalysisMeta.java'
+++ /dev/null
@@ -1,247 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Audio Analysis Metadata objects by creating instances from this class.
- * These objects only contain metadata created by the Analyzer software.
- */
-@JsonDeserialize(builder = AudioAnalysisMeta.Builder.class)
-public class AudioAnalysisMeta extends AbstractModelObject {
- private final String analyzerVersion;
- private final String platform;
- private final String detailedStatus;
- private final Integer statusCode;
- private final Long timestamp;
- private final Float analysisTime;
- private final String inputProcess;
-
- private AudioAnalysisMeta(final Builder builder) {
- super(builder);
-
- this.analyzerVersion = builder.analyzerVersion;
- this.platform = builder.platform;
- this.detailedStatus = builder.detailedStatus;
- this.statusCode = builder.statusCode;
- this.timestamp = builder.timestamp;
- this.analysisTime = builder.analysisTime;
- this.inputProcess = builder.inputProcess;
- }
-
- /**
- * Get the version of the Analyzer software, which is used to create audio analysis data.
- *
- * @return Analyzer software version.
- */
- public String getAnalyzerVersion() {
- return analyzerVersion;
- }
-
- /**
- * Get the platform, on which the audio analysis was created.
- *
- * @return The platform name.
- */
- public String getPlatform() {
- return platform;
- }
-
- /**
- * Get the detailed status of the Analyzer software after creating the audio analysis.
- *
- * @return The detailed status of the Analyzer software.
- */
- public String getDetailedStatus() {
- return detailedStatus;
- }
-
- /**
- * Get the exit status code of the Analyzer software.
- *
- * @return The exit status code. (Should be 0)
- */
- public Integer getStatusCode() {
- return statusCode;
- }
-
- /**
- * Get the timestamp when the audio analysis object has been created by the Analyzer software.
- *
- * @return Timestamp of audio analysis.
- */
- public Long getTimestamp() {
- return timestamp;
- }
-
- /**
- * Get the duration of the audio analysis, eg. in how many seconds the audio analysis has been created by the
- * software.
- *
- * @return Duration of the audio analysis.
- */
- public Float getAnalysisTime() {
- return analysisTime;
- }
-
- /**
- * Get the input process of the audio analysis. The input process is most times the command
- * {@code libvorbisfile L+R 44100->22050}, which lowers the sample rate of the track. (probably to reduce the duration
- * of the audio analysis)
- *
- * @return The input process of the audio analysis.
- */
- public String getInputProcess() {
- return inputProcess;
- }
-
- @Override
- public String toString() {
- return "AudioAnalysisMeta(analyzerVersion=" + analyzerVersion + ", platform=" + platform + ", detailedStatus="
- + detailedStatus + ", statusCode=" + statusCode + ", timestamp=" + timestamp + ", analysisTime=" + analysisTime
- + ", inputProcess=" + inputProcess + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AudioAnalysisMeta} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String analyzerVersion;
- private String platform;
- private String detailedStatus;
- private Integer statusCode;
- private Long timestamp;
- private Float analysisTime;
- private String inputProcess;
-
- /**
- * The Analyzer software version setter.
- *
- * @param analyzerVersion Analyzer software version.
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setAnalyzerVersion(String analyzerVersion) {
- this.analyzerVersion = analyzerVersion;
- return this;
- }
-
- /**
- * The platform setter.
- *
- * @param platform The platform name.
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setPlatform(String platform) {
- this.platform = platform;
- return this;
- }
-
- /**
- * The detailed status setter.
- *
- * @param detailedStatus The detailed status of the Analyzer software.
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setDetailedStatus(String detailedStatus) {
- this.detailedStatus = detailedStatus;
- return this;
- }
-
- /**
- * The status code setter.
- *
- * @param statusCode The exit status code. (Should be 0)
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setStatusCode(Integer statusCode) {
- this.statusCode = statusCode;
- return this;
- }
-
- /**
- * The timestamp setter.
- *
- * @param timestamp Timestamp of audio analysis.
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setTimestamp(Long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * The analysis time setter.
- *
- * @param analysisTime Duration of the audio analysis.
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setAnalysisTime(Float analysisTime) {
- this.analysisTime = analysisTime;
- return this;
- }
-
- /**
- * The input process setter.
- *
- * @param inputProcess The input process of the audio analysis.
- * @return An {@link AudioAnalysisMeta.Builder}.
- */
- public Builder setInputProcess(String inputProcess) {
- this.inputProcess = inputProcess;
- return this;
- }
-
- @Override
- public AudioAnalysisMeta build() {
- return new AudioAnalysisMeta(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AudioAnalysisMeta} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AudioAnalysisMeta createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AudioAnalysisMeta.Builder()
- .setAnalysisTime(
- hasAndNotNull(jsonObject, "analysis_time")
- ? jsonObject.get("analysis_time").getAsFloat()
- : null)
- .setAnalyzerVersion(
- hasAndNotNull(jsonObject, "analyzer_version")
- ? jsonObject.get("analyzer_version").getAsString()
- : null)
- .setDetailedStatus(
- hasAndNotNull(jsonObject, "detailed_status")
- ? jsonObject.get("detailed_status").getAsString()
- : null)
- .setInputProcess(
- hasAndNotNull(jsonObject, "input_process")
- ? jsonObject.get("input_process").getAsString()
- : null)
- .setPlatform(
- hasAndNotNull(jsonObject, "platform")
- ? jsonObject.get("platform").getAsString()
- : null)
- .setStatusCode(
- hasAndNotNull(jsonObject, "status_code")
- ? jsonObject.get("status_code").getAsInt()
- : null)
- .setTimestamp(
- hasAndNotNull(jsonObject, "timestamp")
- ? jsonObject.get("timestamp").getAsLong()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/AudioAnalysisSection.java'
+++ /dev/null
@@ -1,332 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.enums.Modality;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Audio Analysis Section objects by creating instances from this class.
- * Sections are defined by large variations in rhythm or timbre, e.g. chorus, verse, bridge, guitar solo, etc. Each
- * section contains its own descriptions of tempo, key, mode, time_signature, and loudness.
- */
-@JsonDeserialize(builder = AudioAnalysisSection.Builder.class)
-public class AudioAnalysisSection extends AbstractModelObject {
- private final AudioAnalysisMeasure measure;
- private final Float loudness;
- private final Float tempo;
- private final Float tempoConfidence;
- private final Integer key;
- private final Float keyConfidence;
- private final Modality mode;
- private final Float modeConfidence;
- private final Integer timeSignature;
- private final Float timeSignatureConfidence;
-
- private AudioAnalysisSection(final Builder builder) {
- super(builder);
-
- this.measure = builder.measure;
- this.loudness = builder.loudness;
- this.tempo = builder.tempo;
- this.tempoConfidence = builder.tempoConfidence;
- this.key = builder.key;
- this.keyConfidence = builder.keyConfidence;
- this.mode = builder.mode;
- this.modeConfidence = builder.modeConfidence;
- this.timeSignature = builder.timeSignature;
- this.timeSignatureConfidence = builder.timeSignatureConfidence;
- }
-
- /**
- * Get the measure of the audio analysis section object. This measure contains the start point, duration and
- * confidence of the section.
- *
- * @return The measure of the audio analysis section object.
- */
- public AudioAnalysisMeasure getMeasure() {
- return measure;
- }
-
- /**
- * Get the (average) loudness of the section in decibels.
- *
- * @return The loudness of the section.
- */
- public Float getLoudness() {
- return loudness;
- }
-
- /**
- * Get the (estimated) tempo of the section in beats per minute.
- *
- * @return The tempo of the section.
- */
- public Float getTempo() {
- return tempo;
- }
-
- /**
- * Get the tempo confidence of the section.
- *
- * @return The tempo confidence of the section.
- */
- public Float getTempoConfidence() {
- return tempoConfidence;
- }
-
- /**
- * Get the main key of the section.
- *
- * @return Main key of the section.
- * @see Wikipedia: Pitch class notation
- */
- public Integer getKey() {
- return key;
- }
-
- /**
- * Get the key confidence of the section.
- *
- * @return The key confidence of the section.
- */
- public Float getKeyConfidence() {
- return keyConfidence;
- }
-
- /**
- * Get the modality of the section. (either "major" or "minor")
- *
- * @return The modality type of the section.
- * @see Wikipedia: Mode (music)
- */
- public Modality getMode() {
- return mode;
- }
-
- /**
- * Get the modality confidence of the section.
- *
- * @return The modality confidence of the section.
- */
- public Float getModeConfidence() {
- return modeConfidence;
- }
-
- /**
- * Get the estimated overall time signature of the section. The time signature (or meter) is the number of beats in a
- * bar.
- * Example: A Viennese waltz has a three-quarters beat, so this method would return the value 3 in this case.
- *
- * @return Time signature value of the section.
- */
- public Integer getTimeSignature() {
- return timeSignature;
- }
-
- /**
- * Get the time signature confidence of the section.
- *
- * @return The time signature confidence of the section.
- */
- public Float getTimeSignatureConfidence() {
- return timeSignatureConfidence;
- }
-
- @Override
- public String toString() {
- return "AudioAnalysisSection(measure=" + measure + ", loudness=" + loudness + ", tempo=" + tempo
- + ", tempoConfidence=" + tempoConfidence + ", key=" + key + ", keyConfidence=" + keyConfidence + ", mode="
- + mode + ", modeConfidence=" + modeConfidence + ", timeSignature=" + timeSignature
- + ", timeSignatureConfidence=" + timeSignatureConfidence + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AudioAnalysisSection} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private AudioAnalysisMeasure measure;
- private Float loudness;
- private Float tempo;
- private Float tempoConfidence;
- private Integer key;
- private Float keyConfidence;
- private Modality mode;
- private Float modeConfidence;
- private Integer timeSignature;
- private Float timeSignatureConfidence;
-
- /**
- * The measure setter.
- *
- * @param measure The measure of the audio analysis section object.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setMeasure(AudioAnalysisMeasure measure) {
- this.measure = measure;
- return this;
- }
-
- /**
- * The loudness setter.
- *
- * @param loudness The loudness of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setLoudness(Float loudness) {
- this.loudness = loudness;
- return this;
- }
-
- /**
- * The tempo setter.
- *
- * @param tempo The tempo of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setTempo(Float tempo) {
- this.tempo = tempo;
- return this;
- }
-
- /**
- * The tempo confidence setter.
- *
- * @param tempoConfidence The tempo confidence of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setTempoConfidence(Float tempoConfidence) {
- this.tempoConfidence = tempoConfidence;
- return this;
- }
-
- /**
- * The key setter.
- *
- * @param key Main key of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setKey(Integer key) {
- this.key = key;
- return this;
- }
-
- /**
- * The key confidence setter.
- *
- * @param keyConfidence The key confidence of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setKeyConfidence(Float keyConfidence) {
- this.keyConfidence = keyConfidence;
- return this;
- }
-
- /**
- * The mode setter.
- *
- * @param mode The modality type of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setMode(Modality mode) {
- this.mode = mode;
- return this;
- }
-
- /**
- * The mode confidence setter.
- *
- * @param modeConfidence The modality confidence of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setModeConfidence(Float modeConfidence) {
- this.modeConfidence = modeConfidence;
- return this;
- }
-
- /**
- * The time signature setter.
- *
- * @param timeSignature Time signature value of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setTimeSignature(Integer timeSignature) {
- this.timeSignature = timeSignature;
- return this;
- }
-
- /**
- * The time signature confidence setter.
- *
- * @param timeSignatureConfidence The time signature confidence of the section.
- * @return An {@link AudioAnalysisSection.Builder}.
- */
- public Builder setTimeSignatureConfidence(Float timeSignatureConfidence) {
- this.timeSignatureConfidence = timeSignatureConfidence;
- return this;
- }
-
- @Override
- public AudioAnalysisSection build() {
- return new AudioAnalysisSection(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AudioAnalysisSection} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AudioAnalysisSection createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AudioAnalysisSection.Builder()
- .setKey(
- hasAndNotNull(jsonObject, "key")
- ? jsonObject.get("key").getAsInt()
- : null)
- .setKeyConfidence(
- hasAndNotNull(jsonObject, "key_confidence")
- ? jsonObject.get("key_confidence").getAsFloat()
- : null)
- .setLoudness(
- hasAndNotNull(jsonObject, "loudness")
- ? jsonObject.get("loudness").getAsFloat()
- : null)
- .setMeasure(
- new AudioAnalysisMeasure.JsonUtil().createModelObject(jsonObject))
- .setMode(
- hasAndNotNull(jsonObject, "type")
- ? Modality.keyOf(
- jsonObject.get("mode").getAsInt())
- : null)
- .setModeConfidence(
- hasAndNotNull(jsonObject, "mode_confidence")
- ? jsonObject.get("mode_confidence").getAsFloat()
- : null)
- .setTempo(
- hasAndNotNull(jsonObject, "tempo")
- ? jsonObject.get("tempo").getAsFloat()
- : null)
- .setTempoConfidence(
- hasAndNotNull(jsonObject, "tempo_confidence")
- ? jsonObject.get("tempo_confidence").getAsFloat()
- : null)
- .setTimeSignature(
- hasAndNotNull(jsonObject, "time_signature")
- ? jsonObject.get("time_signature").getAsInt()
- : null)
- .setTimeSignatureConfidence(
- hasAndNotNull(jsonObject, "time_signature_confidence")
- ? jsonObject.get("time_signature_confidence").getAsFloat()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/AudioAnalysisSegment.java'
+++ /dev/null
@@ -1,257 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Audio Analysis Segments by creating instances from this class.
- * Segments are sound entities (typically under a second) each relatively uniform in timbre and harmony. They are
- * characterized by their perceptual onsets and duration in seconds, loudness (dB), pitch and timbral content.
- */
-@JsonDeserialize(builder = AudioAnalysisSegment.Builder.class)
-public class AudioAnalysisSegment extends AbstractModelObject {
- private final AudioAnalysisMeasure measure;
- private final Float loudnessStart;
- private final Float loudnessMaxTime;
- private final Float loudnessMax;
- private final Float loudnessEnd;
- private final float[] pitches;
- private final float[] timbre;
-
- private AudioAnalysisSegment(final Builder builder) {
- super(builder);
-
- this.measure = builder.measure;
- this.loudnessStart = builder.loudnessStart;
- this.loudnessMaxTime = builder.loudnessMaxTime;
- this.loudnessMax = builder.loudnessMax;
- this.loudnessEnd = builder.loudnessEnd;
- this.pitches = builder.pitches;
- this.timbre = builder.timbre;
- }
-
- /**
- * Get the measure of the audio analysis segment object. This measure contains the start point, duration and
- * confidence of the segment.
- *
- * @return The measure of the audio analysis segment object.
- */
- public AudioAnalysisMeasure getMeasure() {
- return measure;
- }
-
- /**
- * Get the loudness level at the start of the segment.
- *
- * @return The loudness level at the start of the segment.
- */
- public Float getLoudnessStart() {
- return loudnessStart;
- }
-
- /**
- * Get the offset within the segment of the point of maximum loudness.
- *
- * @return The offset within the segment of the point of maximum loudness.
- */
- public Float getLoudnessMaxTime() {
- return loudnessMaxTime;
- }
-
- /**
- * Get the peak loudness value within the segment.
- *
- * @return The peak loudness value within the segment.
- */
- public Float getLoudnessMax() {
- return loudnessMax;
- }
-
- /**
- * Get the loudness level at the end of the segment. This is only specified in the last segment of the audio analysis.
- *
- * @return The loudness level at the end of the segment.
- */
- public Float getLoudnessEnd() {
- return loudnessEnd;
- }
-
- /**
- * Get the pitches of the segment.
- *
- * Pitch content is given by a "chroma" vector, corresponding to the 12 pitch classes C, C#, D to B, with values
- * ranging from 0 to 1 that describe the relative dominance of every pitch in the chromatic scale. For example a C
- * Major chord would likely be represented by large values of C, E and G (i.e. classes 0, 4, and 7). Vectors are
- * normalized to 1 by their strongest dimension, therefore noisy sounds are likely represented by values that are all
- * close to 1, while pure tones are described by one value at 1 (the pitch) and others near
- *
- * @return The pitches of the segment.
- */
- public float[] getPitches() {
- return pitches;
- }
-
- /**
- * Get the timbre of the segment.
- *
- * The timbre is the quality of a musical note or sound that distinguishes different types of musical instruments, or
- * voices. It is a complex notion also referred to as sound color, texture, or tone quality, and is derived from the
- * shape of a segments spectro-temporal surface, independently of pitch and loudness.
- *
- * @return The timbre of the track.
- */
- public float[] getTimbre() {
- return timbre;
- }
-
- @Override
- public String toString() {
- return "AudioAnalysisSegment(measure=" + measure + ", loudnessStart=" + loudnessStart + ", loudnessMaxTime="
- + loudnessMaxTime + ", loudnessMax=" + loudnessMax + ", loudnessEnd=" + loudnessEnd + ", pitches="
- + Arrays.toString(pitches) + ", timbre=" + Arrays.toString(timbre) + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AudioAnalysisSegment} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private AudioAnalysisMeasure measure;
- private Float loudnessStart;
- private Float loudnessMaxTime;
- private Float loudnessMax;
- private Float loudnessEnd;
- private float[] pitches;
- private float[] timbre;
-
- /**
- * The measure setter.
- *
- * @param measure The measure of the audio analysis segment object.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setMeasure(AudioAnalysisMeasure measure) {
- this.measure = measure;
- return this;
- }
-
- /**
- * The start loudness setter.
- *
- * @param loudnessStart The loudness level at the start of the segment.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setLoudnessStart(Float loudnessStart) {
- this.loudnessStart = loudnessStart;
- return this;
- }
-
- /**
- * The max loudness time setter.
- *
- * @param loudnessMaxTime The offset within the segment of the point of maximum loudness.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setLoudnessMaxTime(Float loudnessMaxTime) {
- this.loudnessMaxTime = loudnessMaxTime;
- return this;
- }
-
- /**
- * The max loudness setter.
- *
- * @param loudnessMax The peak loudness value within the segment.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setLoudnessMax(Float loudnessMax) {
- this.loudnessMax = loudnessMax;
- return this;
- }
-
- /**
- * The end loudness setter.
- *
- * @param loudnessEnd The loudness level at the end of the segment.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setLoudnessEnd(Float loudnessEnd) {
- this.loudnessEnd = loudnessEnd;
- return this;
- }
-
- /**
- * The pitches setter.
- *
- * @param pitches The pitches of the segment.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setPitches(float[] pitches) {
- this.pitches = pitches;
- return this;
- }
-
- /**
- * The timbre setter.
- *
- * @param timbre The timbre of the track.
- * @return An {@link AudioAnalysisSegment.Builder}.
- */
- public Builder setTimbre(float[] timbre) {
- this.timbre = timbre;
- return this;
- }
-
- @Override
- public AudioAnalysisSegment build() {
- return new AudioAnalysisSegment(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AudioAnalysisSegment} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AudioAnalysisSegment createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AudioAnalysisSegment.Builder()
- .setLoudnessEnd(
- hasAndNotNull(jsonObject, "loudness_end")
- ? jsonObject.get("loudness_end").getAsFloat()
- : null)
- .setLoudnessMax(
- hasAndNotNull(jsonObject, "loudness_max")
- ? jsonObject.get("loudness_max").getAsFloat()
- : null)
- .setLoudnessMaxTime(
- hasAndNotNull(jsonObject, "loudness_max_time")
- ? jsonObject.get("loudness_max_time").getAsFloat()
- : null)
- .setLoudnessStart(
- hasAndNotNull(jsonObject, "loudness_start")
- ? jsonObject.get("loudness_start").getAsFloat()
- : null)
- .setMeasure(
- new AudioAnalysisMeasure.JsonUtil().createModelObject(jsonObject))
- .setPitches(
- hasAndNotNull(jsonObject, "pitches")
- ? new Gson().fromJson(jsonObject.getAsJsonArray("pitches"), float[].class)
- : null)
- .setTimbre(
- hasAndNotNull(jsonObject, "timbre")
- ? new Gson().fromJson(jsonObject.getAsJsonArray("timbre"), float[].class)
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/AudioAnalysisTrack.java'
+++ /dev/null
@@ -1,787 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.enums.Modality;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Audio Analysis Track objects by creating instances from this class.
- */
-@JsonDeserialize(builder = AudioAnalysisTrack.Builder.class)
-public class AudioAnalysisTrack extends AbstractModelObject {
- private final Long numSamples;
- private final Float duration;
- private final String sampleMd5;
- private final Integer offsetSeconds;
- private final Integer windowSeconds;
- private final Long analysisSampleRate;
- private final Integer analysisChannels;
- private final Float endOfFadeIn;
- private final Float startOfFadeOut;
- private final Float loudness;
- private final Float tempo;
- private final Float tempoConfidence;
- private final Integer timeSignature;
- private final Float timeSignatureConfidence;
- private final Integer key;
- private final Float keyConfidence;
- private final Modality mode;
- private final Float modeConfidence;
- private final String codeString;
- private final Float codeVersion;
- private final String echoprintString;
- private final Float echoprintVersion;
- private final String synchString;
- private final Float synchVersion;
- private final String rhythmString;
- private final Float rhythmVersion;
-
- private AudioAnalysisTrack(final Builder builder) {
- super(builder);
- this.numSamples = builder.numSamples;
- this.duration = builder.duration;
- this.sampleMd5 = builder.sampleMd5;
- this.offsetSeconds = builder.offsetSeconds;
- this.windowSeconds = builder.windowSeconds;
- this.analysisSampleRate = builder.analysisSampleRate;
- this.analysisChannels = builder.analysisChannels;
- this.endOfFadeIn = builder.endOfFadeIn;
- this.startOfFadeOut = builder.startOfFadeOut;
- this.loudness = builder.loudness;
- this.tempo = builder.tempo;
- this.tempoConfidence = builder.tempoConfidence;
- this.timeSignature = builder.timeSignature;
- this.timeSignatureConfidence = builder.timeSignatureConfidence;
- this.key = builder.key;
- this.keyConfidence = builder.keyConfidence;
- this.mode = builder.mode;
- this.modeConfidence = builder.modeConfidence;
- this.codeString = builder.codeString;
- this.codeVersion = builder.codeVersion;
- this.echoprintString = builder.echoprintString;
- this.echoprintVersion = builder.echoprintVersion;
- this.synchString = builder.synchString;
- this.synchVersion = builder.synchVersion;
- this.rhythmString = builder.rhythmString;
- this.rhythmVersion = builder.rhythmVersion;
- }
-
- /**
- * Get the number of samples in the track.
- * The total number of samples is calculated by multiplying the duration of the track with the sample rate.
- *
- * @return The total number of samples in the track.
- */
- public Long getNumSamples() {
- return numSamples;
- }
-
- /**
- * Get the duration of the track in seconds.
- *
- * @return The duration of the track in seconds.
- */
- public Float getDuration() {
- return duration;
- }
-
- /**
- * Get the sample MD5.
- *
- * Note: The sample MD5 is probably the MD5 of the track file. In the documentation of the Analyzer
- * software, this field is mentioned in an example and contains a value, but it seems that audio analysis objects
- * returned by the Spotify Web API doesn't include a value in the field anymore.
- *
- * @return The sample MD5.
- */
- public String getSampleMd5() {
- return sampleMd5;
- }
-
- /**
- * Get the offset seconds.
- * Note: There is no public documentation available for this field.
- *
- * @return The offset seconds.
- */
- public Integer getOffsetSeconds() {
- return offsetSeconds;
- }
-
- /**
- * Get the window seconds.
- * Note: There is no public documentation available for this field.
- *
- * @return The window seconds.
- */
- public Integer getWindowSeconds() {
- return windowSeconds;
- }
-
- /**
- * Get the sample rate in which the audio analysis was performed.
- *
- * @return The analysis sample rate.
- */
- public Long getAnalysisSampleRate() {
- return analysisSampleRate;
- }
-
- /**
- * Get the analysis channels.
- *
- * @return The analysis channels.
- */
- public Integer getAnalysisChannels() {
- return analysisChannels;
- }
-
- /**
- * Get the end of fade in introduction of the track.
- *
- * @return The end of fade in introduction in seconds.
- */
- public Float getEndOfFadeIn() {
- return endOfFadeIn;
- }
-
- /**
- * Get the start of the fade out in seconds.
- *
- * @return The start of the fade out in seconds.
- */
- public Float getStartOfFadeOut() {
- return startOfFadeOut;
- }
-
- /**
- * Get the average loudness of the track in decibels. These values are mostly in a range between -60 and 0 decibels.
- *
- * @return Average loudness of the track.
- */
- public Float getLoudness() {
- return loudness;
- }
-
- /**
- * Get the estimated tempo of the track in beats per minute.
- *
- * @return The estimated tempo of the track.
- */
- public Float getTempo() {
- return tempo;
- }
-
- /**
- * Get the tempo confidence of the track.
- *
- * @return The tempo confidence of the track.
- */
- public Float getTempoConfidence() {
- return tempoConfidence;
- }
-
- /**
- * Get the estimated overall time signature of the track. The time signature (or meter) is the number of beats in a
- * bar.
- * Example: A Viennese waltz has a three-quarters beat, so this method would return the value 3 in this case.
- *
- * @return Time signature value.
- */
- public Integer getTimeSignature() {
- return timeSignature;
- }
-
- /**
- * Get the time signature confidence of the track.
- *
- * @return The time signature confidence.
- */
- public Float getTimeSignatureConfidence() {
- return timeSignatureConfidence;
- }
-
- /**
- * Get the estimated main key of the track.
- *
- * @return Main key of the track.
- * @see Wikipedia: Pitch class notation
- */
- public Integer getKey() {
- return key;
- }
-
- /**
- * Get the key confidence of the track.
- *
- * @return The key confidence of the track.
- */
- public Float getKeyConfidence() {
- return keyConfidence;
- }
-
- /**
- * Get the modality of the track. (either "major" or "minor")
- *
- * @return The modality type of the track.
- * @see Wikipedia: Mode (music)
- */
- public Modality getMode() {
- return mode;
- }
-
- /**
- * Get the modality confidence of the track.
- *
- * @return The modality confidence of the track.
- */
- public Float getModeConfidence() {
- return modeConfidence;
- }
-
- /**
- * Get the code string of the track.
- *
- * Note: The code string is a fingerprint computed on the audio and were used by the Echo Nest services for
- * song identification, which are no longer available.
- *
- * @return The code string of the track.
- */
- public String getCodeString() {
- return codeString;
- }
-
- /**
- * Get the version of the code string.
- *
- * @return The version of the code string.
- */
- public Float getCodeVersion() {
- return codeVersion;
- }
-
- /**
- * Get the echoprint string of the track.
- *
- * Note: The echoprint string is a fingerprint computed on the audio and were used by the Echo Nest services
- * for song identification, which are no longer available.
- *
- * @return The echoprint string of the track.
- */
- public String getEchoprintString() {
- return echoprintString;
- }
-
- /**
- * Get the version of the echoprint string.
- *
- * @return The version of the echoprint string.
- */
- public Float getEchoprintVersion() {
- return echoprintVersion;
- }
-
- /**
- * Get the synch string of the track.
- *
- * It works with a simple synchronization algorithm to be implemented on the client side, which generates offset
- * values in numbers of samples for 3 locations in the decoded waveform, the beginning, the middle, and the end. These
- * offsets allow the client application to detect decoding errors (when offsets mismatch). They provide for synching
- * with sample accuracy, the JSON timing data with the waveform, regardless of which mp3 decoder was used on the
- * client side (quicktime, ffmpeg, mpg123, etc).
- *
- * @return The synch string.
- */
- public String getSynchString() {
- return synchString;
- }
-
- /**
- * Get the version of the synch string.
- *
- * @return The synch string version.
- */
- public Float getSynchVersion() {
- return synchVersion;
- }
-
- /**
- * Get the rhythm string of the track.
- *
- *
- * @return The rhythm string of the track.
- */
- public String getRhythmString() {
- return rhythmString;
- }
-
- /**
- * Get the version of the rhythm string.
- *
- * @return The rhythm string version.
- */
- public Float getRhythmVersion() {
- return rhythmVersion;
- }
-
- @Override
- public String toString() {
- return "AudioAnalysisTrack(numSamples=" + numSamples + ", duration=" + duration + ", sampleMd5=" + sampleMd5
- + ", offsetSeconds=" + offsetSeconds + ", windowSeconds=" + windowSeconds + ", analysisSampleRate="
- + analysisSampleRate + ", analysisChannels=" + analysisChannels + ", endOfFadeIn=" + endOfFadeIn
- + ", startOfFadeOut=" + startOfFadeOut + ", loudness=" + loudness + ", tempo=" + tempo + ", tempoConfidence="
- + tempoConfidence + ", timeSignature=" + timeSignature + ", timeSignatureConfidence=" + timeSignatureConfidence
- + ", key=" + key + ", keyConfidence=" + keyConfidence + ", mode=" + mode + ", modeConfidence=" + modeConfidence
- + ", codeString=" + codeString + ", codeVersion=" + codeVersion + ", echoprintString=" + echoprintString
- + ", echoprintVersion=" + echoprintVersion + ", synchString=" + synchString + ", synchVersion=" + synchVersion
- + ", rhythmString=" + rhythmString + ", rhythmVersion=" + rhythmVersion + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AudioAnalysisTrack} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private Long numSamples;
- private Float duration;
- private String sampleMd5;
- private Integer offsetSeconds;
- private Integer windowSeconds;
- private Long analysisSampleRate;
- private Integer analysisChannels;
- private Float endOfFadeIn;
- private Float startOfFadeOut;
- private Float loudness;
- private Float tempo;
- private Float tempoConfidence;
- private Integer timeSignature;
- private Float timeSignatureConfidence;
- private Integer key;
- private Float keyConfidence;
- private Modality mode;
- private Float modeConfidence;
- private String codeString;
- private Float codeVersion;
- private String echoprintString;
- private Float echoprintVersion;
- private String synchString;
- private Float synchVersion;
- private String rhythmString;
- private Float rhythmVersion;
-
- /**
- * The sample number setter.
- *
- * @param numSamples The total number of samples in the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setNumSamples(Long numSamples) {
- this.numSamples = numSamples;
- return this;
- }
-
- /**
- * The track duration setter.
- *
- * @param duration The duration of the track in seconds.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setDuration(Float duration) {
- this.duration = duration;
- return this;
- }
-
- /**
- * The sample MD5 setter.
- *
- * @param sampleMd5 The sample MD5.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setSampleMd5(String sampleMd5) {
- this.sampleMd5 = sampleMd5;
- return this;
- }
-
- /**
- * The offset seconds setter.
- *
- * @param offsetSeconds The offset seconds.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setOffsetSeconds(Integer offsetSeconds) {
- this.offsetSeconds = offsetSeconds;
- return this;
- }
-
- /**
- * The window seconds setter.
- *
- * @param windowSeconds The window seconds.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setWindowSeconds(Integer windowSeconds) {
- this.windowSeconds = windowSeconds;
- return this;
- }
-
- /**
- * The analysis sample rate setter.
- *
- * @param analysisSampleRate The analysis sample rate.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setAnalysisSampleRate(Long analysisSampleRate) {
- this.analysisSampleRate = analysisSampleRate;
- return this;
- }
-
- /**
- * The analysis channels setter.
- *
- * @param analysisChannels The analysis channels.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setAnalysisChannels(Integer analysisChannels) {
- this.analysisChannels = analysisChannels;
- return this;
- }
-
- /**
- * The end of fade in introduction setter.
- *
- * @param endOfFadeIn The end of fade in introduction in seconds.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setEndOfFadeIn(Float endOfFadeIn) {
- this.endOfFadeIn = endOfFadeIn;
- return this;
- }
-
- /**
- * The start of fade out setter.
- *
- * @param startOfFadeOut The start of the fade out in seconds.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setStartOfFadeOut(Float startOfFadeOut) {
- this.startOfFadeOut = startOfFadeOut;
- return this;
- }
-
- /**
- * The average loudness setter.
- *
- * @param loudness Average loudness of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setLoudness(Float loudness) {
- this.loudness = loudness;
- return this;
- }
-
- /**
- * The estimated tempo setter.
- *
- * @param tempo The estimated tempo of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setTempo(Float tempo) {
- this.tempo = tempo;
- return this;
- }
-
- /**
- * The tempo confidence setter.
- *
- * @param tempoConfidence The tempo confidence of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setTempoConfidence(Float tempoConfidence) {
- this.tempoConfidence = tempoConfidence;
- return this;
- }
-
- /**
- * The time signature setter.
- *
- * @param timeSignature Time signature value.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setTimeSignature(Integer timeSignature) {
- this.timeSignature = timeSignature;
- return this;
- }
-
- /**
- * The time signature confidence setter.
- *
- * @param timeSignatureConfidence The time signature confidence.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setTimeSignatureConfidence(Float timeSignatureConfidence) {
- this.timeSignatureConfidence = timeSignatureConfidence;
- return this;
- }
-
- /**
- * The track key setter.
- *
- * @param key Main key of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setKey(Integer key) {
- this.key = key;
- return this;
- }
-
- /**
- * The key confidence setter.
- *
- * @param keyConfidence The key confidence of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setKeyConfidence(Float keyConfidence) {
- this.keyConfidence = keyConfidence;
- return this;
- }
-
- /**
- * The track modality setter.
- *
- * @param mode The modality type of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setMode(Modality mode) {
- this.mode = mode;
- return this;
- }
-
- /**
- * The modality confidence setter.
- *
- * @param modeConfidence The modality confidence of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setModeConfidence(Float modeConfidence) {
- this.modeConfidence = modeConfidence;
- return this;
- }
-
- /**
- * The code string setter.
- *
- * @param codeString The code string of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setCodeString(String codeString) {
- this.codeString = codeString;
- return this;
- }
-
- /**
- * The code string version setter.
- *
- * @param codeVersion The version of the code string.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setCodeVersion(Float codeVersion) {
- this.codeVersion = codeVersion;
- return this;
- }
-
- /**
- * The echoprint string setter.
- *
- * @param echoprintString The echoprint string of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setEchoprintString(String echoprintString) {
- this.echoprintString = echoprintString;
- return this;
- }
-
- /**
- * The echoprint string version setter.
- *
- * @param echoprintVersion The version of the echoprint string.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setEchoprintVersion(Float echoprintVersion) {
- this.echoprintVersion = echoprintVersion;
- return this;
- }
-
- /**
- * The synch string setter.
- *
- * @param synchString The synch string.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setSynchString(String synchString) {
- this.synchString = synchString;
- return this;
- }
-
- /**
- * The synch string version setter.
- *
- * @param synchVersion The synch string version.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setSynchVersion(Float synchVersion) {
- this.synchVersion = synchVersion;
- return this;
- }
-
- /**
- * The rhythm string setter.
- *
- * @param rhythmString The rhythm string of the track.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setRhythmString(String rhythmString) {
- this.rhythmString = rhythmString;
- return this;
- }
-
- /**
- * The rhythm string version setter.
- *
- * @param rhythmVersion The rhythm string version.
- * @return An {@link AudioAnalysisTrack.Builder}.
- */
- public Builder setRhythmVersion(Float rhythmVersion) {
- this.rhythmVersion = rhythmVersion;
- return this;
- }
-
- @Override
- public AudioAnalysisTrack build() {
- return new AudioAnalysisTrack(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AudioAnalysisTrack} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AudioAnalysisTrack createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AudioAnalysisTrack.Builder()
- .setAnalysisChannels(
- hasAndNotNull(jsonObject, "analysis_channels")
- ? jsonObject.get("analysis_channels").getAsInt()
- : null)
- .setAnalysisSampleRate(
- hasAndNotNull(jsonObject, "analysis_sample_rate")
- ? jsonObject.get("analysis_sample_rate").getAsLong()
- : null)
- .setCodeString(
- hasAndNotNull(jsonObject, "code_string")
- ? jsonObject.get("code_string").getAsString()
- : null)
- .setCodeVersion(
- hasAndNotNull(jsonObject, "code_version")
- ? jsonObject.get("code_version").getAsFloat()
- : null)
- .setDuration(
- hasAndNotNull(jsonObject, "duration")
- ? jsonObject.get("duration").getAsFloat()
- : null)
- .setEchoprintString(
- hasAndNotNull(jsonObject, "echoprintstring")
- ? jsonObject.get("echoprintstring").getAsString()
- : null)
- .setEchoprintVersion(
- hasAndNotNull(jsonObject, "echoprint_version")
- ? jsonObject.get("echoprint_version").getAsFloat()
- : null)
- .setEndOfFadeIn(
- hasAndNotNull(jsonObject, "end_of_face_in")
- ? jsonObject.get("end_of_face_in").getAsFloat()
- : null)
- .setKey(
- hasAndNotNull(jsonObject, "key")
- ? jsonObject.get("key").getAsInt()
- : null)
- .setKeyConfidence(
- hasAndNotNull(jsonObject, "key_confidence")
- ? jsonObject.get("key_confidence").getAsFloat()
- : null)
- .setLoudness(
- hasAndNotNull(jsonObject, "loudness")
- ? jsonObject.get("loudness").getAsFloat()
- : null)
- .setMode(
- hasAndNotNull(jsonObject, "type")
- ? Modality.keyOf(
- jsonObject.get("mode").getAsInt())
- : null)
- .setModeConfidence(
- hasAndNotNull(jsonObject, "mode_confidence")
- ? jsonObject.get("mode_confidence").getAsFloat()
- : null)
- .setNumSamples(
- hasAndNotNull(jsonObject, "num_samples")
- ? jsonObject.get("num_samples").getAsLong()
- : null)
- .setOffsetSeconds(
- hasAndNotNull(jsonObject, "offset_seconds")
- ? jsonObject.get("offset_seconds").getAsInt()
- : null)
- .setRhythmString(
- hasAndNotNull(jsonObject, "rhythmstring")
- ? jsonObject.get("rhythmstring").getAsString()
- : null)
- .setRhythmVersion(
- hasAndNotNull(jsonObject, "rhythm_version")
- ? jsonObject.get("rhythm_version").getAsFloat()
- : null)
- .setSampleMd5(
- hasAndNotNull(jsonObject, "sample_md5")
- ? jsonObject.get("sample_md5").getAsString()
- : null)
- .setStartOfFadeOut(
- hasAndNotNull(jsonObject, "start_of_fade_out")
- ? jsonObject.get("start_of_fade_out").getAsFloat()
- : null)
- .setSynchString(
- hasAndNotNull(jsonObject, "synchstring")
- ? jsonObject.get("synchstring").getAsString()
- : null)
- .setSynchVersion(
- hasAndNotNull(jsonObject, "synch_version")
- ? jsonObject.get("synch_version").getAsFloat()
- : null)
- .setTempo(
- hasAndNotNull(jsonObject, "tempo")
- ? jsonObject.get("tempo").getAsFloat()
- : null)
- .setTempoConfidence(
- hasAndNotNull(jsonObject, "tempo_confidence")
- ? jsonObject.get("tempo_confidence").getAsFloat()
- : null)
- .setTimeSignature(
- hasAndNotNull(jsonObject, "time_signature")
- ? jsonObject.get("time_signature").getAsInt()
- : null)
- .setTimeSignatureConfidence(
- hasAndNotNull(jsonObject, "time_signature_confidence")
- ? jsonObject.get("time_signature_confidence").getAsFloat()
- : null)
- .setWindowSeconds(
- hasAndNotNull(jsonObject, "windows_seconds")
- ? jsonObject.get("windows_seconds").getAsInt()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/CurrentlyPlaying.java'
+++ /dev/null
@@ -1,258 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.enums.CurrentlyPlayingType;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-import com.wrapper.spotify.model_objects.IPlaylistItem;
-import com.wrapper.spotify.model_objects.special.Actions;
-import com.wrapper.spotify.model_objects.specification.Context;
-import com.wrapper.spotify.model_objects.specification.Disallows;
-import com.wrapper.spotify.model_objects.specification.Episode;
-import com.wrapper.spotify.model_objects.specification.Track;
-
-/**
- * Retrieve information about
- * Currently Playing objects by creating instances from this class.
- */
-@JsonDeserialize(builder = CurrentlyPlaying.Builder.class)
-public class CurrentlyPlaying extends AbstractModelObject {
- private final Context context;
- private final Long timestamp;
- private final Integer progress_ms;
- private final Boolean is_playing;
- private final IPlaylistItem item;
- private final CurrentlyPlayingType currentlyPlayingType;
- private final Actions actions;
-
- private CurrentlyPlaying(final Builder builder) {
- super(builder);
-
- this.context = builder.context;
- this.timestamp = builder.timestamp;
- this.progress_ms = builder.progress_ms;
- this.is_playing = builder.is_playing;
- this.item = builder.item;
- this.currentlyPlayingType = builder.currentlyPlayingType;
- this.actions = builder.actions;
- }
-
- /**
- * Get the context the item was played from.
- *
- * @return The context the item was played from. Can be {@code null}.
- */
- public Context getContext() {
- return context;
- }
-
- /**
- * Get the timestamp when the received data was fetched.
- *
- * @return Unix Millisecond Timestamp when data was fetched.
- */
- public Long getTimestamp() {
- return timestamp;
- }
-
- /**
- * Get the progress of the current played item.
- *
- * @return Progress into the currently playing item. Can be {@code null}.
- */
- public Integer getProgress_ms() {
- return progress_ms;
- }
-
- /**
- * Check if something is played at the moment.
- *
- * @return If something is currently playing.
- */
- public Boolean getIs_playing() {
- return is_playing;
- }
-
- /**
- * Get the currently played track or episode.
- *
- * @return The currently playing track or episode. Can be {@code null}.
- */
- public IPlaylistItem getItem() {
- return item;
- }
-
- /**
- * Get the type of the currently playing item.
- *
- * @return The type of the currently playing item.
- */
- public CurrentlyPlayingType getCurrentlyPlayingType() {
- return currentlyPlayingType;
- }
-
- /**
- * Get which playback actions are available within the current context.
- *
- * @return A {@link Actions} object which contains a {@link Disallows} object.
- */
- public Actions getActions() {
- return actions;
- }
-
- @Override
- public String toString() {
- return "CurrentlyPlaying(context=" + context + ", timestamp=" + timestamp + ", progress_ms=" + progress_ms
- + ", is_playing=" + is_playing + ", item=" + item + ", currentlyPlayingType=" + currentlyPlayingType
- + ", actions=" + actions + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link CurrentlyPlaying} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private Context context;
- private Long timestamp;
- private Integer progress_ms;
- private Boolean is_playing;
- private IPlaylistItem item;
- private CurrentlyPlayingType currentlyPlayingType;
- private Actions actions;
-
- /**
- * The playing context setter.
- *
- * @param context The context the track was played from. Can be {@code null}.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setContext(Context context) {
- this.context = context;
- return this;
- }
-
- /**
- * The timestamp setter.
- *
- * @param timestamp Unix Millisecond Timestamp when data was fetched.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setTimestamp(Long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * The current track progress setter.
- *
- * @param progress_ms Progress into the currently playing track. Can be {@code null}.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setProgress_ms(Integer progress_ms) {
- this.progress_ms = progress_ms;
- return this;
- }
-
- /**
- * The playing state setter.
- *
- * @param is_playing If something is currently playing.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setIs_playing(Boolean is_playing) {
- this.is_playing = is_playing;
- return this;
- }
-
- /**
- * The currently playing item setter.
- *
- * @param item The currently playing item. Can be {@code null}.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setItem(IPlaylistItem item) {
- this.item = item;
- return this;
- }
-
- /**
- * The currently playing type setter.
- *
- * @param currentlyPlayingType The type of the currently playing item.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setCurrentlyPlayingType(CurrentlyPlayingType currentlyPlayingType) {
- this.currentlyPlayingType = currentlyPlayingType;
- return this;
- }
-
- /**
- * The actions setter.
- *
- * @param actions A {@link Actions} object which contains a {@link Disallows} object.
- * @return A {@link CurrentlyPlaying.Builder}.
- */
- public Builder setActions(Actions actions) {
- this.actions = actions;
- return this;
- }
-
- @Override
- public CurrentlyPlaying build() {
- return new CurrentlyPlaying(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link CurrentlyPlaying} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public CurrentlyPlaying createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new CurrentlyPlaying.Builder()
- .setContext(
- hasAndNotNull(jsonObject, "context")
- ? new Context.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("context"))
- : null)
- .setTimestamp(
- hasAndNotNull(jsonObject, "timestamp")
- ? jsonObject.get("timestamp").getAsLong()
- : null)
- .setProgress_ms(
- hasAndNotNull(jsonObject, "progress_ms")
- ? jsonObject.get("progress_ms").getAsInt()
- : null)
- .setIs_playing(
- hasAndNotNull(jsonObject, "is_playing")
- ? jsonObject.get("is_playing").getAsBoolean()
- : null)
- .setItem(
- hasAndNotNull(jsonObject, "item") && hasAndNotNull(jsonObject, "currently_playing_type")
- ? (jsonObject.get("currently_playing_type").getAsString().equals("track")
- ? new Track.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item"))
- : jsonObject.get("currently_playing_type").getAsString().equals("episode")
- ? new Episode.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item"))
- : null)
- : null)
- .setCurrentlyPlayingType(
- hasAndNotNull(jsonObject, "currently_playing_type")
- ? CurrentlyPlayingType.keyOf(
- jsonObject.get("currently_playing_type").getAsString().toLowerCase())
- : null)
- .setActions(
- hasAndNotNull(jsonObject, "actions")
- ? new Actions.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("actions"))
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/CurrentlyPlayingContext.java'
+++ /dev/null
@@ -1,342 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.enums.CurrentlyPlayingType;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-import com.wrapper.spotify.model_objects.IPlaylistItem;
-import com.wrapper.spotify.model_objects.special.Actions;
-import com.wrapper.spotify.model_objects.specification.Context;
-import com.wrapper.spotify.model_objects.specification.Disallows;
-import com.wrapper.spotify.model_objects.specification.Episode;
-import com.wrapper.spotify.model_objects.specification.Track;
-
-/**
- * Retrieve information about
- * Currently Playing
- * Context objects by creating instances from this class.
- */
-@JsonDeserialize(builder = CurrentlyPlayingContext.Builder.class)
-public class CurrentlyPlayingContext extends AbstractModelObject {
- private final Device device;
- private final String repeat_state;
- private final Boolean shuffle_state;
- private final Context context;
- private final Long timestamp;
- private final Integer progress_ms;
- private final Boolean is_playing;
- private final IPlaylistItem item;
- private final CurrentlyPlayingType currentlyPlayingType;
- private final Actions actions;
-
- private CurrentlyPlayingContext(final Builder builder) {
- super(builder);
-
- this.device = builder.device;
- this.repeat_state = builder.repeat_state;
- this.shuffle_state = builder.shuffle_state;
- this.context = builder.context;
- this.timestamp = builder.timestamp;
- this.progress_ms = builder.progress_ms;
- this.is_playing = builder.is_playing;
- this.item = builder.item;
- this.currentlyPlayingType = builder.currentlyPlayingType;
- this.actions = builder.actions;
- }
-
- /**
- * Get the currently active device.
- *
- * @return The device that is currently active.
- */
- public Device getDevice() {
- return device;
- }
-
- /**
- * Get the repeat state of the device. (No repeat, track repeat, context repeat)
- *
- * @return The repeat state.
- */
- public String getRepeat_state() {
- return repeat_state;
- }
-
- /**
- * Get the shuffle state of the device.
- *
- * @return If shuffle is on or off.
- */
- public Boolean getShuffle_state() {
- return shuffle_state;
- }
-
- /**
- * Get the context from where the currently playing item is played from.
- *
- * @return A Context Object. Can be {@code null}.
- */
- public Context getContext() {
- return context;
- }
-
- /**
- * Get the Unix timestamp in milliseconds when the time was fetched.
- *
- * @return Unix Millisecond Timestamp when data was fetched.
- */
- public Long getTimestamp() {
- return timestamp;
- }
-
- /**
- * Get the progress of the currently playing item.
- *
- * @return Progress into the currently playing item. Can be {@code null}.
- */
- public Integer getProgress_ms() {
- return progress_ms;
- }
-
- /**
- * Check whether a track or episode is playing on the device or not.
- *
- * @return If something is currently playing.
- */
- public Boolean getIs_playing() {
- return is_playing;
- }
-
- /**
- * Get the currently playing track or episode, if the device is playing something.
- *
- * @return The currently playing item. Can be {@code null}.
- */
- public IPlaylistItem getItem() {
- return item;
- }
-
- /**
- * Get the type of the currently playing item.
- *
- * @return The type of the currently playing item.
- */
- public CurrentlyPlayingType getCurrentlyPlayingType() {
- return currentlyPlayingType;
- }
-
- /**
- * Get which playback actions are available within the current context.
- *
- * @return A {@link Actions} object which contains a {@link Disallows} object.
- */
- public Actions getActions() {
- return actions;
- }
-
- @Override
- public String toString() {
- return "CurrentlyPlayingContext(device=" + device + ", repeat_state=" + repeat_state + ", shuffle_state="
- + shuffle_state + ", context=" + context + ", timestamp=" + timestamp + ", progress_ms=" + progress_ms
- + ", is_playing=" + is_playing + ", item=" + item + ", currentlyPlayingType=" + currentlyPlayingType
- + ", actions=" + actions + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link CurrentlyPlayingContext} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private Device device;
- private String repeat_state;
- private Boolean shuffle_state;
- private Context context;
- private Long timestamp;
- private Integer progress_ms;
- private Boolean is_playing;
- private IPlaylistItem item;
- private CurrentlyPlayingType currentlyPlayingType;
- private Actions actions;
-
- /**
- * The active device setter.
- *
- * @param device The device that is currently active.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setDevice(Device device) {
- this.device = device;
- return this;
- }
-
- /**
- * The repeat state setter.
- *
- * @param repeat_state The repeat state.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setRepeat_state(String repeat_state) {
- this.repeat_state = repeat_state;
- return this;
- }
-
- /**
- * The shuffle state setter.
- *
- * @param shuffle_state If shuffle is on or off.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setShuffle_state(Boolean shuffle_state) {
- this.shuffle_state = shuffle_state;
- return this;
- }
-
- /**
- * The playing context setter.
- *
- * @param context A Context Object. Can be {@code null}.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setContext(Context context) {
- this.context = context;
- return this;
- }
-
- /**
- * The timestamp setter.
- *
- * @param timestamp Unix Millisecond Timestamp when data was fetched.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setTimestamp(Long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * The item progress setter.
- *
- * @param progress_ms Progress into the currently playing item. Can be {@code null}.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setProgress_ms(Integer progress_ms) {
- this.progress_ms = progress_ms;
- return this;
- }
-
- /**
- * The playing state setter.
- *
- * @param is_playing If something is currently playing.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setIs_playing(Boolean is_playing) {
- this.is_playing = is_playing;
- return this;
- }
-
- /**
- * The currently playing item setter.
- *
- * @param item If something is currently playing.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setItem(IPlaylistItem item) {
- this.item = item;
- return this;
- }
-
- /**
- * The currently playing type setter.
- *
- * @param currentlyPlayingType The type of the currently playing item.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setCurrentlyPlayingType(CurrentlyPlayingType currentlyPlayingType) {
- this.currentlyPlayingType = currentlyPlayingType;
- return this;
- }
-
- /**
- * The actions setter.
- *
- * @param actions A {@link Actions} object which contains a {@link Disallows} object.
- * @return A {@link CurrentlyPlayingContext.Builder}.
- */
- public Builder setActions(Actions actions) {
- this.actions = actions;
- return this;
- }
-
- @Override
- public CurrentlyPlayingContext build() {
- return new CurrentlyPlayingContext(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link CurrentlyPlayingContext} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public CurrentlyPlayingContext createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new Builder()
- .setDevice(
- hasAndNotNull(jsonObject, "device")
- ? new Device.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("device"))
- : null)
- .setRepeat_state(
- hasAndNotNull(jsonObject, "repeat_state")
- ? jsonObject.get("repeat_state").getAsString()
- : null)
- .setShuffle_state(
- hasAndNotNull(jsonObject, "shuffle_state")
- ? jsonObject.get("shuffle_state").getAsBoolean()
- : null)
- .setContext(
- hasAndNotNull(jsonObject, "context")
- ? new Context.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("context"))
- : null)
- .setTimestamp(
- hasAndNotNull(jsonObject, "timestamp")
- ? jsonObject.get("timestamp").getAsLong()
- : null)
- .setProgress_ms(
- hasAndNotNull(jsonObject, "progress_ms")
- ? jsonObject.get("progress_ms").getAsInt()
- : null)
- .setIs_playing(
- hasAndNotNull(jsonObject, "is_playing")
- ? jsonObject.get("is_playing").getAsBoolean()
- : null)
- .setItem(
- hasAndNotNull(jsonObject, "item") && hasAndNotNull(jsonObject, "currently_playing_type")
- ? (jsonObject.get("currently_playing_type").getAsString().equals("track")
- ? new Track.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item"))
- : jsonObject.get("currently_playing_type").getAsString().equals("episode")
- ? new Episode.JsonUtil().createModelObject(jsonObject.getAsJsonObject("item"))
- : null)
- : null)
- .setCurrentlyPlayingType(
- hasAndNotNull(jsonObject, "currently_playing_type")
- ? CurrentlyPlayingType.keyOf(
- jsonObject.get("currently_playing_type").getAsString().toLowerCase())
- : null)
- .setActions(
- hasAndNotNull(jsonObject, "actions")
- ? new Actions.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("actions"))
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/Device.java'
+++ /dev/null
@@ -1,216 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Device
- * objects by creating instances from this class.
- */
-@JsonDeserialize(builder = Device.Builder.class)
-public class Device extends AbstractModelObject {
- private final String id;
- private final Boolean is_active;
- private final Boolean is_restricted;
- private final String name;
- private final String type;
- private final Integer volume_percent;
-
- private Device(final Builder builder) {
- super(builder);
-
- this.id = builder.id;
- this.is_active = builder.is_active;
- this.is_restricted = builder.is_restricted;
- this.name = builder.name;
- this.type = builder.type;
- this.volume_percent = builder.volume_percent;
- }
-
- /**
- * Get the ID of the device.
- *
- * @return The device ID. This may be {@code null}.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Check whether the device is the currently active device.
- *
- * @return If this device is the currently active device.
- */
- public Boolean getIs_active() {
- return is_active;
- }
-
- /**
- * Check whether the device is restricted or not. Restricted devices don't accept Spotify Web API calls.
- *
- * @return Whether controlling this device is restricted.
- */
- public Boolean getIs_restricted() {
- return is_restricted;
- }
-
- /**
- * Get the name of the device.
- *
- * @return The name of the device.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get the type of the device.
- *
- * @return Device type, such as "Computer", "Smartphone" or "Speaker".
- */
- public String getType() {
- return type;
- }
-
- /**
- * Get the current volume of the device in percent.
- *
- * @return The current volume in percent. This may be {@code null}.
- */
- public Integer getVolume_percent() {
- return volume_percent;
- }
-
- @Override
- public String toString() {
- return "Device(id=" + id + ", is_active=" + is_active + ", is_restricted=" + is_restricted + ", name=" + name
- + ", type=" + type + ", volume_percent=" + volume_percent + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link Device} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String id;
- private Boolean is_active;
- private Boolean is_restricted;
- private String name;
- private String type;
- private Integer volume_percent;
-
- /**
- * The device ID setter.
- *
- * @param id The device ID. This may be {@code null}.
- * @return A {@link Device.Builder}.
- */
- public Builder setId(String id) {
- this.id = id;
- return this;
- }
-
- /**
- * The active device state setter.
- *
- * @param is_active If this device is the currently active device.
- * @return A {@link Device.Builder}.
- */
- public Builder setIs_active(Boolean is_active) {
- this.is_active = is_active;
- return this;
- }
-
- /**
- * The device restriction state setter.
- *
- * @param is_restricted Whether controlling this device is restricted.
- * @return A {@link Device.Builder}.
- */
- public Builder setIs_restricted(Boolean is_restricted) {
- this.is_restricted = is_restricted;
- return this;
- }
-
- /**
- * The device name setter.
- *
- * @param name The name of the device.
- * @return A {@link Device.Builder}.
- */
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * The device type setter.
- *
- * @param type Device type, such as "Computer", "Smartphone" or "Speaker".
- * @return A {@link Device.Builder}.
- */
- public Builder setType(String type) {
- this.type = type;
- return this;
- }
-
- /**
- * The device volume setter.
- *
- * @param volume_percent The current volume in percent. This may be {@code null}.
- * @return A {@link Device.Builder}.
- */
- public Builder setVolume_percent(Integer volume_percent) {
- this.volume_percent = volume_percent;
- return this;
- }
-
- @Override
- public Device build() {
- return new Device(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link Device} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public Device createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new Device.Builder()
- .setId(
- hasAndNotNull(jsonObject, "id")
- ? jsonObject.get("id").getAsString()
- : null)
- .setIs_active(
- hasAndNotNull(jsonObject, "is_active")
- ? jsonObject.get("is_active").getAsBoolean()
- : null)
- .setIs_restricted(
- hasAndNotNull(jsonObject, "is_restricted")
- ? jsonObject.get("is_restricted").getAsBoolean()
- : null)
- .setName(
- hasAndNotNull(jsonObject, "name")
- ? jsonObject.get("name").getAsString()
- : null)
- .setType(
- hasAndNotNull(jsonObject, "type")
- ? jsonObject.get("type").getAsString()
- : null)
- .setVolume_percent(
- hasAndNotNull(jsonObject, "volume_percent")
- ? jsonObject.get("volume_percent").getAsInt()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/PlaylistTracksInformation.java'
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Playlist Track Information objects by building instances from this class.
- */
-@JsonDeserialize(builder = PlaylistTracksInformation.Builder.class)
-public class PlaylistTracksInformation extends AbstractModelObject {
- private final String href;
- private final Integer total;
-
- private PlaylistTracksInformation(final Builder builder) {
- super(builder);
-
- this.href = builder.href;
- this.total = builder.total;
- }
-
- /**
- * Get the Spotify Web API endpoint URL of the playlist tracks object.
- *
- * @return A Spotify API endpoint URL.
- */
- public String getHref() {
- return href;
- }
-
- /**
- * Get the total amount of tracks in the playlist.
- *
- * @return The total amount of tracks in the playlist.
- */
- public Integer getTotal() {
- return total;
- }
-
- @Override
- public String toString() {
- return "PlaylistTracksInformation(href=" + href + ", total=" + total + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link PlaylistTracksInformation} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String href;
- private Integer total;
-
- /**
- * Set href of Spotify Web API endpoint of the playlist tracks information object to be built.
- *
- * @param href Spotify Web API endpoint URL.
- * @return A {@link PlaylistTracksInformation.Builder}.
- */
- public Builder setHref(String href) {
- this.href = href;
- return this;
- }
-
- /**
- * Set the total amount of tracks in the playlist.
- *
- * @param total Total amount of tracks.
- * @return A {@link PlaylistTracksInformation.Builder}.
- */
- public Builder setTotal(Integer total) {
- this.total = total;
- return this;
- }
-
- @Override
- public PlaylistTracksInformation build() {
- return new PlaylistTracksInformation(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link PlaylistTracksInformation} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public PlaylistTracksInformation createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new PlaylistTracksInformation.Builder()
- .setHref(
- hasAndNotNull(jsonObject, "href")
- ? jsonObject.get("href").getAsString()
- : null)
- .setTotal(
- hasAndNotNull(jsonObject, "total")
- ? jsonObject.get("total").getAsInt()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/README.md'
+++ /dev/null
@@ -1,3 +0,0 @@
-# Miscellaneous Objects
-
-Objects, that are defined on an API endpoint reference page, but not within the [main object model](https://developer.spotify.com/documentation/web-api/reference/object-model/).
\ No newline at end of file
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/miscellaneous/Restrictions.java'
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.wrapper.spotify.model_objects.miscellaneous;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Restriction objects by building instances from this class.
- *
- * Part of the response when Track Relinking
- * is applied, the original track is not available in the given market, and Spotify did not have any tracks to relink it
- * with. The track response will still contain metadata for the original track, and a restrictions object containing the
- * reason why the track is not available
- */
-@JsonDeserialize(builder = Restrictions.Builder.class)
-public class Restrictions extends AbstractModelObject {
- private final String reason;
-
- private Restrictions(final Builder builder) {
- super(builder);
-
- this.reason = builder.reason;
- }
-
- /**
- * Get the reason why the track is not available.
- *
- * @return The track restriction reason.
- */
- public String getReason() {
- return reason;
- }
-
- @Override
- public String toString() {
- return "Restrictions(reason=" + reason + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link Restrictions} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String reason;
-
- /**
- * The restriction reason setter.
- *
- * @param reason The track restriction reason.
- * @return A {@link Restrictions.Builder}.
- */
- public Builder setReason(String reason) {
- this.reason = reason;
- return this;
- }
-
- @Override
- public Restrictions build() {
- return new Restrictions(this);
- }
- }
-
- /**
- * JSonUtil class for building {@link Restrictions} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public Restrictions createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new Restrictions.Builder()
- .setReason(
- hasAndNotNull(jsonObject, "reason")
- ? jsonObject.get("reason").getAsString()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/special/Actions.java'
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.wrapper.spotify.model_objects.special;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-import com.wrapper.spotify.model_objects.specification.Disallows;
-
-/**
- * Retrieve information about Actions objects by building instances from this class. These objects
- * contain information to allow to update the user interface based on which playback actions are
- * available within the current context. These objects contain a {@link Disallows} object.
- */
-@JsonDeserialize(builder = Actions.Builder.class)
-public class Actions extends AbstractModelObject {
- private final Disallows disallows;
-
- public Actions(Builder builder) {
- super(builder);
- this.disallows = builder.disallows;
- }
-
- /**
- * Get the Disallows object.
- *
- * @return Disallows object.
- */
- public Disallows getDisallows() {
- return disallows;
- }
-
- @Override
- public String toString() {
- return "Actions(disallows=" + disallows + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link Actions} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private Disallows disallows;
-
- /**
- * Set the Disallows object of the Actions object to be built.
- *
- * @param disallows The {@link Disallows} object.
- * @return A {@link Actions.Builder}.
- */
- public Builder setDisallows(Disallows disallows) {
- this.disallows = disallows;
- return this;
- }
-
- @Override
- public Actions build() {
- return new Actions(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link Actions} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- @Override
- public Actions createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new Builder()
- .setDisallows(
- hasAndNotNull(jsonObject, "disallows")
- ? new Disallows.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("disallows"))
- : null)
- .build();
- }
- }
-
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/special/AlbumSimplifiedSpecial.java'
+++ /dev/null
@@ -1,436 +0,0 @@
-package com.wrapper.spotify.model_objects.special;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.neovisionaries.i18n.CountryCode;
-import com.wrapper.spotify.enums.AlbumType;
-import com.wrapper.spotify.enums.ModelObjectType;
-import com.wrapper.spotify.enums.ReleaseDatePrecision;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-import com.wrapper.spotify.model_objects.specification.Album;
-import com.wrapper.spotify.model_objects.specification.ArtistSimplified;
-import com.wrapper.spotify.model_objects.specification.ExternalUrl;
-import com.wrapper.spotify.model_objects.specification.Image;
-import com.wrapper.spotify.requests.data.search.interfaces.ISearchModelObject;
-
-/**
- * Retrieve information about
- * simplified Album objects by building instances from this class.
- *
- * This class exists because it includes the property {@code totalTracks}, which is not documented in the official
- * specification, although the albums object as returned by the searches API includes it.
- */
-@JsonDeserialize(builder = AlbumSimplifiedSpecial.Builder.class)
-public class AlbumSimplifiedSpecial extends AbstractModelObject implements ISearchModelObject {
- private final AlbumType albumType;
- private final ArtistSimplified[] artists;
- private final CountryCode[] availableMarkets;
- private final ExternalUrl externalUrls;
- private final String href;
- private final String id;
- private final Image[] images;
- private final String name;
- private final String releaseDate;
- private final ReleaseDatePrecision releaseDatePrecision;
- private final Integer totalTracks;
- private final ModelObjectType type;
- private final String uri;
-
- private AlbumSimplifiedSpecial(final Builder builder) {
- super(builder);
-
- this.albumType = builder.albumType;
- this.artists = builder.artists;
- this.availableMarkets = builder.availableMarkets;
- this.externalUrls = builder.externalUrls;
- this.href = builder.href;
- this.id = builder.id;
- this.images = builder.images;
- this.name = builder.name;
- this.releaseDate = builder.releaseDate;
- this.releaseDatePrecision = builder.releaseDatePrecision;
- this.totalTracks = builder.totalTracks;
- this.type = builder.type;
- this.uri = builder.uri;
- }
-
- /**
- * Get the type of the album.
- *
- * @return The {@link AlbumType}.
- */
- public AlbumType getAlbumType() {
- return albumType;
- }
-
- /**
- * Get the artists of the album.
- *
- * @return An array of {@link ArtistSimplified} objects.
- */
- public ArtistSimplified[] getArtists() {
- return artists;
- }
-
- /**
- * Get the country codes of all countries, in which the album is available.
- *
- * @return An array of ISO 3166-1 alpha-2 country
- * codes.
- */
- public CountryCode[] getAvailableMarkets() {
- return availableMarkets;
- }
-
- /**
- * Get the external URLs of the album.
- * Example: Spotify-URL
- *
- * @return An {@link ExternalUrl} object.
- */
- public ExternalUrl getExternalUrls() {
- return externalUrls;
- }
-
- /**
- * Get the full Spotify Web API endpoint URL of the album.
- *
- * @return A Spotify Web API endpoint URL.
- */
- public String getHref() {
- return href;
- }
-
- /**
- * Get the Spotify ID of the album.
- *
- * @return A Spotify album ID.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Get the album cover art of the album in different sizes.
- *
- * @return An array of {@link Image} objects.
- */
- public Image[] getImages() {
- return images;
- }
-
- /**
- * Get the name of the album.
- *
- * @return Album name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get the release date of the album with the highest precision available.
- *
- * @return The release date of the album.
- */
- public String getReleaseDate() {
- return releaseDate;
- }
-
- /**
- * 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.
- */
- public ReleaseDatePrecision getReleaseDatePrecision() {
- return releaseDatePrecision;
- }
-
- /**
- * Get the total tracks of the album.
- *
- * @return The total tracks of the album.
- */
- public Integer getTotalTracks() {
- return totalTracks;
- }
-
- /**
- * Get the model object type. In this case "album".
- *
- * @return A {@link ModelObjectType}.
- */
- public ModelObjectType getType() {
- return type;
- }
-
- /**
- * Get the Spotify URI of the album.
- *
- * @return Spotify album URI.
- */
- public String getUri() {
- return uri;
- }
-
- @Override
- public String toString() {
- return "AlbumSimplifiedSpecial(albumType=" + albumType + ", artists=" + Arrays.toString(artists)
- + ", availableMarkets=" + Arrays.toString(availableMarkets) + ", externalUrls=" + externalUrls + ", href="
- + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", name=" + name + ", releaseDate="
- + releaseDate + ", releaseDatePrecision=" + releaseDatePrecision + ", totalTracks=" + totalTracks + ", type="
- + type + ", uri=" + uri + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link AlbumSimplifiedSpecial} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
-
- private AlbumType albumType;
- private ArtistSimplified[] artists;
- private CountryCode[] availableMarkets;
- private ExternalUrl externalUrls;
- private String href;
- private String id;
- private Image[] images;
- private String name;
- private String releaseDate;
- private ReleaseDatePrecision releaseDatePrecision;
- private Integer totalTracks;
- private ModelObjectType type;
- private String uri;
-
- /**
- * Set the type of the album to be built.
- *
- * @param albumType The {@link AlbumType}.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setAlbumType(AlbumType albumType) {
- this.albumType = albumType;
- return this;
-
- }
-
- /**
- * Set the artists of the album to be built.
- *
- * @param artists {@link ArtistSimplified} objects.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setArtists(ArtistSimplified... artists) {
- this.artists = artists;
- return this;
- }
-
- /**
- * Set the available markets of the album to be built.
- *
- * @param availableMarkets
- * ISO 3166-1 alpha-2 country codes.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setAvailableMarkets(CountryCode... availableMarkets) {
- this.availableMarkets = availableMarkets;
- return this;
- }
-
- /**
- * Set external URLs of the album to be built.
- *
- * @param externalUrls {@link ExternalUrl} object.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setExternalUrls(ExternalUrl externalUrls) {
- this.externalUrls = externalUrls;
- return this;
- }
-
- /**
- * Set href of Spotify Web API endpoint of the album to be built.
- *
- * @param href Spotify Web API endpoint URL.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setHref(String href) {
- this.href = href;
- return this;
- }
-
- /**
- * Set album ID of the album to be built.
- *
- * @param id Spotify album ID.
- * @return A {@link Album.Builder}.
- */
- public Builder setId(String id) {
- this.id = id;
- return this;
- }
-
- /**
- * Set the cover art in different sizes of the album to be built.
- *
- * @param images {@link Image} objects.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setImages(Image... images) {
- this.images = images;
- return this;
- }
-
- /**
- * Set the name of the album to be built.
- *
- * @param name The album name.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * Set the release date of the album to be built.
- *
- * @param releaseDate The release date of the album.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setReleaseDate(String releaseDate) {
- this.releaseDate = releaseDate;
- return this;
- }
-
- /**
- * Set the release date precision of the album to be built.
- *
- * @param releaseDatePrecision The {@link ReleaseDatePrecision} of the album.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setReleaseDatePrecision(ReleaseDatePrecision releaseDatePrecision) {
- this.releaseDatePrecision = releaseDatePrecision;
- return this;
- }
-
- /**
- * Set the number of total tracks of the album to be built.
- *
- * @param totalTracks The number of total tracks of the album.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setTotalTracks(Integer totalTracks) {
- this.totalTracks = totalTracks;
- return this;
- }
-
- /**
- * Set the type of the model object. In this case "album".
- *
- * @param type The {@link ModelObjectType}.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setType(ModelObjectType type) {
- this.type = type;
- return this;
- }
-
- /**
- * Set the Spotify album URI of the album to be built.
- *
- * @param uri
- * Spotify album URI.
- * @return A {@link AlbumSimplifiedSpecial.Builder}.
- */
- public Builder setUri(String uri) {
- this.uri = uri;
- return this;
- }
-
- @Override
- public AlbumSimplifiedSpecial build() {
- return new AlbumSimplifiedSpecial(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link AlbumSimplifiedSpecial} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public AlbumSimplifiedSpecial createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new AlbumSimplifiedSpecial.Builder()
- .setAlbumType(
- hasAndNotNull(jsonObject, "album_type")
- ? AlbumType.keyOf(
- jsonObject.get("album_type").getAsString().toLowerCase())
- : null)
- .setArtists(
- hasAndNotNull(jsonObject, "artists")
- ? new ArtistSimplified.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("artists"))
- : null)
- .setAvailableMarkets(
- hasAndNotNull(jsonObject, "available_markets")
- ? new Gson().fromJson(
- jsonObject.get("available_markets"), CountryCode[].class)
- : null)
- .setExternalUrls(
- hasAndNotNull(jsonObject, "external_urls")
- ? new ExternalUrl.JsonUtil().createModelObject(
- jsonObject.getAsJsonObject("external_urls"))
- : null)
- .setHref(
- hasAndNotNull(jsonObject, "href")
- ? jsonObject.get("href").getAsString()
- : null)
- .setId(
- hasAndNotNull(jsonObject, "id")
- ? jsonObject.get("id").getAsString()
- : null)
- .setImages(
- hasAndNotNull(jsonObject, "images")
- ? new Image.JsonUtil().createModelObjectArray(
- jsonObject.getAsJsonArray("images"))
- : null)
- .setName(
- hasAndNotNull(jsonObject, "name")
- ? jsonObject.get("name").getAsString()
- : null)
- .setReleaseDate(
- hasAndNotNull(jsonObject, "release_date")
- ? jsonObject.get("release_date").getAsString()
- : null)
- .setReleaseDatePrecision(
- hasAndNotNull(jsonObject, "release_date_precision")
- ? ReleaseDatePrecision.keyOf(
- jsonObject.get("release_date_precision").getAsString().toLowerCase())
- : null)
- .setTotalTracks(
- hasAndNotNull(jsonObject, "total_tracks")
- ? jsonObject.get("total_tracks").getAsInt()
- : null)
- .setType(
- hasAndNotNull(jsonObject, "type")
- ? ModelObjectType.keyOf(
- jsonObject.get("type").getAsString().toLowerCase())
- : null)
- .setUri(
- hasAndNotNull(jsonObject, "uri")
- ? jsonObject.get("uri").getAsString()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/special/FeaturedPlaylists.java'
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.wrapper.spotify.model_objects.special;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-import com.wrapper.spotify.model_objects.specification.Paging;
-import com.wrapper.spotify.model_objects.specification.PlaylistSimplified;
-
-/**
- * Retrieve information about
- * Featured Playlist objects by building instances from this class.
- */
-@JsonDeserialize(builder = FeaturedPlaylists.Builder.class)
-public class FeaturedPlaylists extends AbstractModelObject {
- private final String message;
- private final Paging playlists;
-
- private FeaturedPlaylists(final Builder builder) {
- super(builder);
-
- this.message = builder.message;
- this.playlists = builder.playlists;
- }
-
- /**
- * Get the message which is displayed on the front page of the "browse" tab in the Spotify client.
- * The message usually refers to the featured playlists.
- *
- * @return A "welcoming" message.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Get the page of featured playlists.
- *
- * @return Featured playlists page.
- */
- public Paging getPlaylists() {
- return playlists;
- }
-
- @Override
- public String toString() {
- return "FeaturedPlaylists(message=" + message + ", playlists=" + playlists + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link FeaturedPlaylists} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String message;
- private Paging playlists;
-
- /**
- * Set the message, which normally would be displayed on the front page of the "browse" tab.
- *
- * @param message Message to be set.
- * @return A {@link FeaturedPlaylists.Builder}.
- */
- public Builder setMessage(String message) {
- this.message = message;
- return this;
- }
-
- /**
- * Set a page of playlists contained in the featured playlists object to be built.
- *
- * @param playlists A page of simplified playlists.
- * @return A {@link FeaturedPlaylists.Builder}.
- */
- public Builder setPlaylists(Paging playlists) {
- this.playlists = playlists;
- return this;
- }
-
- @Override
- public FeaturedPlaylists build() {
- return new FeaturedPlaylists(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link FeaturedPlaylists} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public FeaturedPlaylists createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new FeaturedPlaylists.Builder()
- .setMessage(
- hasAndNotNull(jsonObject, "message")
- ? jsonObject.get("message").getAsString()
- : null)
- .setPlaylists(
- hasAndNotNull(jsonObject, "playlists")
- ? new PlaylistSimplified.JsonUtil().createModelObjectPaging(
- jsonObject.getAsJsonObject("playlists"))
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/special/PlaylistTrackPosition.java'
+++ /dev/null
@@ -1,100 +0,0 @@
-package com.wrapper.spotify.model_objects.special;
-
-import java.util.Arrays;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-
-/**
- * Retrieve information about Playlist Track Position objects by building instances from this class. These objects
- * contain the position in a playlist, where tracks should be added in a request.
- */
-@JsonDeserialize(builder = PlaylistTrackPosition.Builder.class)
-public class PlaylistTrackPosition extends AbstractModelObject {
- private final String uri;
- private final int[] positions;
-
- public PlaylistTrackPosition(final Builder builder) {
- super(builder);
-
- this.uri = builder.uri;
- this.positions = builder.positions;
- }
-
- /**
- * Get the Spotify URI of the
- * track.
- *
- * @return Spotify track URI.
- */
- public String getUri() {
- return uri;
- }
-
- /**
- * Get the position, where the track should be added in the playlist.
- *
- * @return Track position.
- */
- public int[] getPositions() {
- return positions;
- }
-
- @Override
- public String toString() {
- return "PlaylistTrackPosition(uri=" + uri + ", positions=" + Arrays.toString(positions) + ")";
- }
-
- @Override
- public Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for building {@link PlaylistTrackPosition} instances.
- */
- public static final class Builder extends AbstractModelObject.Builder {
- private String uri;
- private int[] positions;
-
- public Builder setUri(String uri) {
- this.uri = uri;
- return this;
- }
-
- public Builder setPositions(int... positions) {
- this.positions = positions;
- return this;
- }
-
- @Override
- public PlaylistTrackPosition build() {
- return new PlaylistTrackPosition(this);
- }
- }
-
- /**
- * JsonUtil class for building {@link PlaylistTrackPosition} instances.
- */
- public static final class JsonUtil extends AbstractModelObject.JsonUtil {
- public PlaylistTrackPosition createModelObject(JsonObject jsonObject) {
- if (jsonObject == null || jsonObject.isJsonNull()) {
- return null;
- }
-
- return new PlaylistTrackPosition.Builder()
- .setPositions(
- hasAndNotNull(jsonObject, "positions")
- ? new Gson().fromJson(
- jsonObject.getAsJsonArray("positions"), int[].class)
- : null)
- .setUri(
- hasAndNotNull(jsonObject, "uri")
- ? jsonObject.get("uri").getAsString()
- : null)
- .build();
- }
- }
-}
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/special/README.md'
+++ /dev/null
@@ -1,3 +0,0 @@
-# Special Objects
-
-Objects, that are nowhere defined, but returned by requests.
\ No newline at end of file
--- 'a/spotify/src/main/java/com/stream_pi/spotify/model_objects/special/SearchResult.java'
+++ /dev/null
@@ -1,240 +0,0 @@
-package com.wrapper.spotify.model_objects.special;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.google.gson.JsonObject;
-import com.wrapper.spotify.model_objects.AbstractModelObject;
-import com.wrapper.spotify.model_objects.specification.*;
-import com.wrapper.spotify.requests.data.personalization.interfaces.IArtistTrackModelObject;
-import com.wrapper.spotify.requests.data.search.SearchItemRequest;
-import com.wrapper.spotify.requests.data.search.interfaces.ISearchModelObject;
-
-/**
- * Retrieve the searched-for items by building instances from this class. This objects contains
- * for every type specified by the {@code type} parameter in the {@link SearchItemRequest}
- * the searched-for items wrapped in a {@link Paging} object.
- */
-@JsonDeserialize(builder = SearchResult.Builder.class)
-public class SearchResult extends AbstractModelObject implements IArtistTrackModelObject, ISearchModelObject {
- private final Paging albums;
- private final Paging artists;
- private final Paging episodes;
- private final Paging playlists;
- private final Paging shows;
- private final Paging