Class AbstractModelObject.JsonUtil<T>
java.lang.Object
se.michaelthelin.spotify.model_objects.AbstractModelObject.JsonUtil<T>
- Type Parameters:
T- The model object type of the corresponding JsonUtil.
- All Implemented Interfaces:
IModelObject.IJsonUtil<T>
- Direct Known Subclasses:
Actions.JsonUtil, Album.JsonUtil, AlbumSimplified.JsonUtil, AlbumSimplifiedSpecial.JsonUtil, Artist.JsonUtil, ArtistSimplified.JsonUtil, AudioAnalysis.JsonUtil, AudioAnalysisMeasure.JsonUtil, AudioAnalysisMeta.JsonUtil, AudioAnalysisSection.JsonUtil, AudioAnalysisSegment.JsonUtil, AudioAnalysisTrack.JsonUtil, Audiobook.JsonUtil, AudiobookSimplified.JsonUtil, AudioFeatures.JsonUtil, AuthenticationError.JsonUtil, Author.JsonUtil, AuthorizationCodeCredentials.JsonUtil, Category.JsonUtil, Chapter.JsonUtil, ChapterRestriction.JsonUtil, ChapterSimplified.JsonUtil, ClientCredentials.JsonUtil, Context.JsonUtil, Copyright.JsonUtil, CurrentlyPlaying.JsonUtil, CurrentlyPlayingContext.JsonUtil, Cursor.JsonUtil, Device.JsonUtil, Disallows.JsonUtil, Episode.JsonUtil, EpisodeSimplified.JsonUtil, Error.JsonUtil, ExplicitContentSettings.JsonUtil, ExternalId.JsonUtil, ExternalUrl.JsonUtil, FeaturedPlaylists.JsonUtil, Followers.JsonUtil, Image.JsonUtil, Narrator.JsonUtil, PlaybackQueue.JsonUtil, PlayHistory.JsonUtil, Playlist.JsonUtil, PlaylistSimplified.JsonUtil, PlaylistTrack.JsonUtil, PlaylistTracksInformation.JsonUtil, Recommendations.JsonUtil, RecommendationsSeed.JsonUtil, Restrictions.JsonUtil, ResumePoint.JsonUtil, SavedAlbum.JsonUtil, SavedEpisode.JsonUtil, SavedShow.JsonUtil, SavedTrack.JsonUtil, SearchResult.JsonUtil, Show.JsonUtil, ShowSimplified.JsonUtil, SnapshotResult.JsonUtil, Track.JsonUtil, TrackLink.JsonUtil, TrackSimplified.JsonUtil, User.JsonUtil
- Enclosing class:
AbstractModelObject
public abstract static class AbstractModelObject.JsonUtil<T>
extends Object
implements IModelObject.IJsonUtil<T>
Each model object needs to implement its own JsonUtil class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateModelObject(com.google.gson.JsonObject jsonObject) Deserializes a model object reflectively.createModelObject(String json) Build a model object with the information given in a json string.T[]createModelObjectArray(com.google.gson.JsonArray jsonArray) Create an array of model objects out of a json array object.T[]createModelObjectArray(String json) Create an array of model objects out of a json string.T[]createModelObjectArray(String json, String key) Create an array of model objects out of a json array, which is contained in a json object.createModelObjectPaging(com.google.gson.JsonObject jsonObject) Create a paging of model objects out of a json object.Create a paging of model objects out of a json string.createModelObjectPaging(String json, String key) Create a paging of model objects out of a json array, which is contained in a json object.createModelObjectPagingCursorbased(com.google.gson.JsonObject jsonObject) Create a cursor-based paging of model objects out of a json object.Create a cursor-based paging of model objects out of a json string.createModelObjectPagingCursorbased(String json, String key) Create a cursor-based paging of model objects out of a json array, which is contained in a json object.booleanhasAndNotNull(com.google.gson.JsonObject jsonObject, String memberName) Check whether the supplied JSON object contains data in the given member, which is notnull.protected TypeThe model type this JsonUtil produces, taken from the type argument it was declared with.
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
createModelObject
Deserializes a model object reflectively.Every model object whose JSON mirrors its fields inherits this. The three whose shape does not (
Disallowsand the two external-identifier maps) override it, andModelObjectGsonroutes nested occurrences of those back through the override.- Specified by:
createModelObjectin interfaceIModelObject.IJsonUtil<T>- Parameters:
jsonObject- The JSON to read, which may benullor JSON null.- Returns:
- The model object, or
null.
-
modelType
The model type this JsonUtil produces, taken from the type argument it was declared with.- Returns:
- The type passed to
Gson.fromJson(JsonElement, Type).
-
hasAndNotNull
Check whether the supplied JSON object contains data in the given member, which is notnull.- Specified by:
hasAndNotNullin interfaceIModelObject.IJsonUtil<T>- Parameters:
jsonObject- The JSON object.memberName- The member name.- Returns:
- Whether the supplied JSON object contains data in the given member.
-
createModelObject
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.- Specified by:
createModelObjectin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- A json object.- Returns:
- A model object. The type depends on this methods implementation.
-
createModelObjectArray
Create an array of model objects out of a json array object.- Specified by:
createModelObjectArrayin interfaceIModelObject.IJsonUtil<T>- Parameters:
jsonArray- AJsonArray.- Returns:
- A model object array. The type depends on this methods implementation.
-
createModelObjectArray
Create an array of model objects out of a json string.- Specified by:
createModelObjectArrayin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- AJsonArray.- Returns:
- A model object array. The type depends on this methods implementation.
-
createModelObjectArray
Create an array of model objects out of a json array, which is contained in a json object.- Specified by:
createModelObjectArrayin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- AJsonObject.key- The key of the json array in the json object.- Returns:
- A model object array. The type depends on this methods implementation.
-
createModelObjectPaging
Create a paging of model objects out of a json object.- Specified by:
createModelObjectPagingin interfaceIModelObject.IJsonUtil<T>- Parameters:
jsonObject- A json object.- Returns:
- A model object paging.
-
createModelObjectPaging
Create a paging of model objects out of a json string.- Specified by:
createModelObjectPagingin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- A json string.- Returns:
- A model object paging.
-
createModelObjectPaging
Create a paging of model objects out of a json array, which is contained in a json object.- Specified by:
createModelObjectPagingin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- AJsonObject.key- The key of the json array in the json object.- Returns:
- A model object array. The type depends on this methods implementation.
-
createModelObjectPagingCursorbased
public PagingCursorbased<T> createModelObjectPagingCursorbased(com.google.gson.JsonObject jsonObject) Create a cursor-based paging of model objects out of a json object.- Specified by:
createModelObjectPagingCursorbasedin interfaceIModelObject.IJsonUtil<T>- Parameters:
jsonObject- A json object.- Returns:
- A cursor-based model object paging.
-
createModelObjectPagingCursorbased
Create a cursor-based paging of model objects out of a json string.- Specified by:
createModelObjectPagingCursorbasedin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- A json string.- Returns:
- A cursor-based model object paging.
-
createModelObjectPagingCursorbased
Create a cursor-based paging of model objects out of a json array, which is contained in a json object.- Specified by:
createModelObjectPagingCursorbasedin interfaceIModelObject.IJsonUtil<T>- Parameters:
json- AJsonObject.key- The key of the json array in the json object.- Returns:
- A cursor-based model object paging.
-