Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java generator: Union type handling #37

Closed
sonallux opened this issue Dec 14, 2020 · 0 comments · Fixed by #60
Closed

Java generator: Union type handling #37

sonallux opened this issue Dec 14, 2020 · 0 comments · Fixed by #60

Comments

@sonallux
Copy link
Owner

With the addition of Episodes and Shows, the Spotify Web API does use union types (for example can Playlists can contain Episodes and/or Tracks). As Java does not natively support unions, any union type is currently mapped to Map<String, Object>, which is not a nice UX.

Once shared super types are added (see #7) the handling of union types in the Java wrapper can be greatly improved.
For example the getPlaylistTrack() method can then be typed with a shared super type:

Paging<SpotifyObject> getPlaylistTracks(...) {
}

The user can then inspect the type property of the SpotifyObject and cast to either Track or Episode. This would require a custom Jackson deserializer that inspects the type property and then creates an instance of the concrete SpotifyObject class (e.g. Artist, Album, Track, Playlist, Show, Episode).

sonallux added a commit that referenced this issue Mar 14, 2021
- Adds support for generating a shared super object type (issue #7)
- Add better union type handling in generator-java (issue #37)

fixes #7
fixes #37
sonallux added a commit that referenced this issue Mar 15, 2021
- Adds support for generating a shared super object type (issue #7)
- Add better union type handling in generator-java (issue #37)

fixes #7
fixes #37
sonallux added a commit that referenced this issue Mar 15, 2021
- Adds support for generating a shared super object type (issue #7)
- Add better union type handling in generator-java (issue #37)

fixes #7
fixes #37
sonallux added a commit that referenced this issue Mar 20, 2021
- Adds support for generating a shared super object type (issue #7)
- Add better union type handling in generator-java (issue #37)

fixes #7
fixes #37
sonallux added a commit that referenced this issue Mar 20, 2021
- Adds support for generating a shared super object type (fixes  #7)
- Add better union type handling in generator-java (fixes #37)
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 a pull request may close this issue.

1 participant