← 输入框|github.com|刷新
Skip to content

feat(models): add ModelObjects, deprecate the JsonUtil classes - #489

Merged
dargmuesli merged 4 commits into
mainfrom
feat/model-objects
Nov 4, 2026
Merged

dargmuesli merged 4 commits into
mainfrom
feat/model-objects

Conversation

@dargmuesli

@dargmuesli dargmuesli commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Step 2 of the alternative plan discussed in #461. This branch is based on #488, because the new internal package is excluded from that API gate; its commit appears in the diff until the gate lands and main has moved past it.

Requests read their responses through a shared Gson instance in a new, unexported se.michaelthelin.spotify.internal package, instead of instantiating a model's JsonUtil only to reach that Gson. The hand-written readers for Disallows, ExternalId, ExternalUrl and PlaybackQueue become Gson type adapters, so those JsonUtil overrides only delegate to super and are kept solely for binary compatibility. The parsing steps are unchanged, so empty or malformed bodies fail exactly as before. The 92 inline assert (x != null); assert (!x.isEmpty()); pairs in the request builders are replaced by Preconditions.assertNotEmpty in the unexported internal package; it is still a Java assertion, so it is a no-op unless assertions are enabled and an AssertionError under -ea. The only difference from the inline statements is the enabling package: the checks now belong to internal rather than to each request's own package, so -ea:se.michaelthelin.spotify.requests no longer turns them on. The test suite is unaffected, as Surefire runs with assertions enabled for the whole library.

The public piece is a new class se.michaelthelin.spotify.model_objects.ModelObjects for callers who read JSON they obtained outside a request, such as cached responses. It has four methods, fromJson, arrayFromJson, pagingFromJson and pagingCursorbasedFromJson, and parses exactly the way the requests do, including enum and date formats and the mixed track and episode playlist items. The signatures take a String rather than Gson types, so they are unaffected if Gson later leaves the public API. There are deliberately no key overloads: adding them later is compatible, removing them would not be.

All JsonUtil classes and IModelObject.IJsonUtil are marked deprecated and point to ModelObjects, for removal in the next major version. Plain @Deprecated rather than forRemoval, because removal warnings are not suppressed inside deprecated code and every model's JsonUtil extends the deprecated base class. japicmp against 10.1.0 reports only additions, 420 tests pass including 6 new ones for ModelObjects, and Javadoc, the examples module and ci/check-docs.py all pass.

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.39344% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.23%. Comparing base (7923243) to head (a90fe14).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ichaelthelin/spotify/internal/ModelObjectJson.java 76.00% 3 Missing and 3 partials ⚠️
...ichaelthelin/spotify/internal/ModelObjectGson.java 87.50% 0 Missing and 4 partials ⚠️
.../michaelthelin/spotify/internal/Preconditions.java 42.85% 0 Missing and 4 partials ⚠️
...n/spotify/model_objects/special/PlaybackQueue.java 0.00% 1 Missing ⚠️
...spotify/model_objects/specification/Disallows.java 0.00% 1 Missing ⚠️
...potify/model_objects/specification/ExternalId.java 0.00% 1 Missing ⚠️
...otify/model_objects/specification/ExternalUrl.java 0.00% 1 Missing ⚠️
...otify/model_objects/utils/PlaylistItemFactory.java 66.66% 0 Missing and 1 partial ⚠️
...uthorization_code/AuthorizationCodeUriRequest.java 75.00% 1 Missing ⚠️
...data/users/GetUsersTopArtistsAndTracksRequest.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #489      +/-   ##
============================================
+ Coverage     46.70%   47.23%   +0.52%     
- Complexity      692      721      +29     
============================================
  Files           209      212       +3     
  Lines          6276     6195      -81     
  Branches        759      574     -185     
============================================
- Hits           2931     2926       -5     
- Misses         2783     2890     +107     
+ Partials        562      379     -183     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…il classes

Requests now call a shared helper in a new, unexported internal package
instead of instantiating a model's JsonUtil only to reach the shared Gson.
The custom readers for Disallows, ExternalId, ExternalUrl and PlaybackQueue
move into Gson adapters, so those JsonUtil overrides only delegate and are
kept solely for binary compatibility.

The parsing steps are unchanged, all tests pass, and japicmp reports no API
change against 10.1.0. The internal package is excluded from the API gate.

Refs #461

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Moving assertions into the internal helper changes package-scoped JVM assertion behavior, causing request validation to accept invalid inputs or enforce checks differently under existing assertion settings.

1 open issue
What changed in this PR

This PR advances the boilerplate-reduction work in #461 by adding a public JSON-reading API and moving shared parsing into an internal package, while retaining deprecated JsonUtil classes for compatibility.

Changes:

  • Adds ModelObjects methods for objects, arrays, and both paging formats, with dedicated tests.
  • Routes request parsing through shared internal helpers and moves custom readers into Gson adapters.
  • Centralizes builder assertions, deprecates legacy JSON utilities, and updates documentation and API-check exclusions.
File Description
src/​test/​java/​se/​michaelthelin/​spotify/​model_objects/​ModelObjectsTest.java Tests the new public JSON readers.
src/​test/​java/​se/​michaelthelin/​spotify/​model_objects/​ModelObjectMappingTest.java Exercises mappings through ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​UnfollowPlaylistRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​simplified/​GetUsersTopTracksRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​simplified/​GetUsersTopArtistsRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​GetUsersTopArtistsAndTracksRequest.java Selects model classes for shared parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​GetUsersProfileRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​GetFollowedArtistsRequest.java Uses shared cursor-paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​GetCurrentUsersProfileRequest.java Uses shared object parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​FollowPlaylistRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​users/​CheckIfUserFollowsPlaylistRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetUsersSavedTracksRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetTracksAudioFeaturesRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetTracksAudioAnalysisRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetTrackRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetSeveralTracksRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetSeveralTracksAudioFeaturesRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​tracks/​GetRecommendationsRequest.java Uses shared object parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​shows/​GetUsersSavedShowsRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​shows/​GetShowRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​shows/​GetShowEpisodesRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​shows/​GetSeveralShowsRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​special/​SearchAlbumsSpecialRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchTracksRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchShowsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchPlaylistsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchEpisodesRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchAudiobooksRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchArtistsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​simplified/​SearchAlbumsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​search/​SearchForItemRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​UpdatePlaylistsItemsReplaceRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​UpdatePlaylistsItemsReplaceDeprecatedRequest.java Migrates legacy request helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​UpdatePlaylistsItemsReorderRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​UpdatePlaylistsItemsReorderDeprecatedRequest.java Migrates legacy request helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​RemovePlaylistItemsRequest.java Shares parsing and string/collection assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​RemovePlaylistItemsDeprecatedRequest.java Migrates legacy request helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetUsersPlaylistsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetPlaylistRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetPlaylistItemsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetPlaylistItemsDeprecatedRequest.java Migrates legacy request helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetPlaylistCoverImageRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetFeaturedPlaylistsRequest.java Uses shared object parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetCurrentUsersPlaylistsRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​GetCategoryPlaylistsRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​CreatePlaylistRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​CreatePlaylistForUserRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​ChangePlaylistDetailsRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​AddItemsToPlaylistRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​AddItemsToPlaylistDeprecatedRequest.java Migrates legacy request helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​playlists/​AddCustomPlaylistCoverImageRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​TogglePlaybackShuffleRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​StartResumePlaybackRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​SkipToPreviousRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​SkipToNextRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​SetRepeatModeRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​SetPlaybackVolumeRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​SeekToPositionRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​PausePlaybackRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​GetUsersQueueRequest.java Uses shared queue parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​GetRecentlyPlayedTracksRequest.java Uses shared cursor-paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​GetPlaybackStateRequest.java Uses shared object parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​GetCurrentlyPlayingTrackRequest.java Uses shared object parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​GetAvailableDevicesRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​player/​AddItemToPlaybackQueueRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​episodes/​GetUsersSavedEpisodesRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​episodes/​GetSeveralEpisodesRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​episodes/​GetEpisodeRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​chapters/​GetSeveralChaptersRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​chapters/​GetChapterRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​categories/​GetSingleBrowseCategoryRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​categories/​GetSeveralBrowseCategoriesRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​audiobooks/​GetUsersSavedAudiobooksRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​audiobooks/​GetSeveralAudiobooksRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​audiobooks/​GetAudiobookRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​audiobooks/​GetAudiobookChaptersRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​artists/​GetSeveralArtistsRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​artists/​GetArtistsTopTracksRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​artists/​GetArtistsRelatedArtistsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​artists/​GetArtistsAlbumsRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​artists/​GetArtistRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​albums/​GetUsersSavedAlbumsRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​albums/​GetSeveralAlbumsRequest.java Uses shared array parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​albums/​GetNewReleasesRequest.java Uses shared paging parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​albums/​GetAlbumTracksRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​albums/​GetAlbumRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​data/​AbstractDataRequest.java Shares access-token assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​authorization/​client_credentials/​ClientCredentialsRequest.java Uses shared credential parsing.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​authorization/​authorization_code/​pkce/​AuthorizationCodePKCERequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​authorization/​authorization_code/​pkce/​AuthorizationCodePKCERefreshRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​authorization/​authorization_code/​AuthorizationCodeUriRequest.java Uses shared builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​authorization/​authorization_code/​AuthorizationCodeRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​authorization/​authorization_code/​AuthorizationCodeRefreshRequest.java Uses shared parsing and assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​requests/​AbstractRequest.java Shares common builder assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​utils/​PlaylistItemFactory.java Parses playlist items through internal helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​User.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​TrackSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​TrackLink.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Track.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ShowSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Show.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​SavedTrack.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​SavedShow.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​SavedEpisode.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​SavedAlbum.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ResumePoint.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​RecommendationsSeed.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Recommendations.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​PlaylistTrack.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​PlaylistSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Playlist.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​PlayHistory.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Narrator.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Image.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Followers.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ExternalUrl.java Deprecates reader; retains delegating override.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ExternalId.java Deprecates reader; retains delegating override.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ExplicitContentSettings.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Error.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​EpisodeSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Episode.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Disallows.java Deprecates reader; retains delegating override.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Cursor.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Copyright.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Context.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ChapterSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ChapterRestriction.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Chapter.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Category.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Author.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​AudioFeatures.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​AudiobookSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Audiobook.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​ArtistSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Artist.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​AlbumSimplified.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​specification/​Album.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​special/​SnapshotResult.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​special/​SearchResult.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​special/​PlaybackQueue.java Deprecates reader; retains delegating override.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​special/​FeaturedPlaylists.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​special/​AlbumSimplifiedSpecial.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​special/​Actions.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​ModelObjects.java Adds four public, string-based JSON readers.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​Restrictions.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​PlaylistTracksInformation.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​Device.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​CurrentlyPlayingContext.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​CurrentlyPlaying.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​AudioAnalysisTrack.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​AudioAnalysisSegment.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​AudioAnalysisSection.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​AudioAnalysisMeta.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​AudioAnalysisMeasure.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​miscellaneous/​AudioAnalysis.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​IModelObject.java Deprecates the IJsonUtil interface.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​credentials/​error/​AuthenticationError.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​credentials/​ClientCredentials.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​credentials/​AuthorizationCodeCredentials.java Deprecates JsonUtil; points to ModelObjects.
src/​main/​java/​se/​michaelthelin/​spotify/​model_objects/​AbstractModelObject.java Deprecates base reader; imports internal Gson.
src/​main/​java/​se/​michaelthelin/​spotify/​internal/​Preconditions.java Adds shared string and collection assertions.
src/​main/​java/​se/​michaelthelin/​spotify/​internal/​ModelObjectJson.java Centralizes response parsing helpers.
src/​main/​java/​se/​michaelthelin/​spotify/​internal/​ModelObjectGson.java Relocates Gson configuration and custom readers.
pom.xml Excludes the internal package from API comparisons.
AGENTS.md Documents internal parsing and public ModelObjects usage.

Review effort: Balanced

Replaces 92 inline "assert (x != null); assert (!x.isEmpty());" pairs in the
request builders with Preconditions.assertNotEmpty in the internal package.
It is still a Java assertion, so it is a no-op unless assertions are enabled.
The enabling package shifts from each request class to Preconditions, which
only matters if assertions are scoped to the requests packages and not to
internal.

Refs #461
Nothing in the library calls them any more, since responses are read through
the shared Gson instance. They are deprecated for removal in the next major
version. Plain @deprecated rather than forRemoval, because removal warnings
are not suppressed inside deprecated code and every model JsonUtil extends
the deprecated base class.

Refs #461
Gives callers who parse JSON they obtained outside a request (cached or
stored responses) a public replacement for the deprecated JsonUtil classes:
fromJson, arrayFromJson, pagingFromJson and pagingCursorbasedFromJson. The
signatures take a String, not Gson types, so they survive Gson leaving the
public API. The JsonUtil deprecation notes now point here.

Refs #461
@dargmuesli
dargmuesli merged commit 4bcca52 into main Nov 4, 2026
11 checks passed
@dargmuesli
dargmuesli deleted the feat/model-objects branch November 4, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants