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, AudioFeatures.JsonUtil, AuthenticationError.JsonUtil, AuthorizationCodeCredentials.JsonUtil, Category.JsonUtil, ClientCredentials.JsonUtil, Context.JsonUtil, Copyright.JsonUtil, CurrentlyPlaying.JsonUtil, CurrentlyPlayingContext.JsonUtil, Cursor.JsonUtil, Device.JsonUtil, Disallows.JsonUtil, Episode.JsonUtil, EpisodeSimplified.JsonUtil, Error.JsonUtil, ExternalId.JsonUtil, ExternalUrl.JsonUtil, FeaturedPlaylists.JsonUtil, Followers.JsonUtil, Image.JsonUtil, Paging.JsonUtil, PagingCursorbased.JsonUtil, PlaybackQueue.JsonUtil, PlayHistory.JsonUtil, Playlist.JsonUtil, PlaylistSimplified.JsonUtil, PlaylistTrack.JsonUtil, PlaylistTrackPosition.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 Details

    • JsonUtil

      public JsonUtil()
  • Method Details

    • hasAndNotNull

      public boolean hasAndNotNull(com.google.gson.JsonObject jsonObject, String memberName)
      Check whether the supplied JSON object contains data in the given member, which is not null.
      Specified by:
      hasAndNotNull in interface IModelObject.IJsonUtil<T>
      Parameters:
      jsonObject - The JSON object.
      memberName - The member name.
      Returns:
      Whether the supplied JSON object contains data in the given member.
    • createModelObject

      public T createModelObject(String json)
      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:
      createModelObject in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A json object.
      Returns:
      A model object. The type depends on this methods implementation.
    • createModelObjectArray

      public T[] createModelObjectArray(com.google.gson.JsonArray jsonArray)
      Create an array of model objects out of a json array object.
      Specified by:
      createModelObjectArray in interface IModelObject.IJsonUtil<T>
      Parameters:
      jsonArray - A JsonArray.
      Returns:
      A model object array. The type depends on this methods implementation.
    • createModelObjectArray

      public T[] createModelObjectArray(String json)
      Create an array of model objects out of a json string.
      Specified by:
      createModelObjectArray in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A JsonArray.
      Returns:
      A model object array. The type depends on this methods implementation.
    • createModelObjectArray

      public T[] createModelObjectArray(String json, String key)
      Create an array of model objects out of a json array, which is contained in a json object.
      Specified by:
      createModelObjectArray in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A JsonObject.
      key - The key of the json array in the json object.
      Returns:
      A model object array. The type depends on this methods implementation.
    • createModelObjectArray

      public <X> X[] createModelObjectArray(com.google.gson.JsonArray jsonArray, Class<X> clazz)
      Create an array of model objects out of a json array object and a Class object.
      Specified by:
      createModelObjectArray in interface IModelObject.IJsonUtil<T>
      Type Parameters:
      X - The model object type of the array and class object.
      Parameters:
      jsonArray - A json array object.
      clazz - The class object.
      Returns:
      A model object array.
    • createModelObjectPaging

      public Paging<T> createModelObjectPaging(com.google.gson.JsonObject jsonObject)
      Create a paging of model objects out of a json object.
      Specified by:
      createModelObjectPaging in interface IModelObject.IJsonUtil<T>
      Parameters:
      jsonObject - A json object.
      Returns:
      A model object paging.
    • createModelObjectPaging

      public Paging<T> createModelObjectPaging(String json)
      Create a paging of model objects out of a json string.
      Specified by:
      createModelObjectPaging in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A json string.
      Returns:
      A model object paging.
    • createModelObjectPaging

      public Paging<T> createModelObjectPaging(String json, String key)
      Create a paging of model objects out of a json array, which is contained in a json object.
      Specified by:
      createModelObjectPaging in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A JsonObject.
      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:
      createModelObjectPagingCursorbased in interface IModelObject.IJsonUtil<T>
      Parameters:
      jsonObject - A json object.
      Returns:
      A cursor-based model object paging.
    • createModelObjectPagingCursorbased

      public PagingCursorbased<T> createModelObjectPagingCursorbased(String json)
      Create a cursor-based paging of model objects out of a json string.
      Specified by:
      createModelObjectPagingCursorbased in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A json string.
      Returns:
      A cursor-based model object paging.
    • createModelObjectPagingCursorbased

      public PagingCursorbased<T> 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.
      Specified by:
      createModelObjectPagingCursorbased in interface IModelObject.IJsonUtil<T>
      Parameters:
      json - A JsonObject.
      key - The key of the json array in the json object.
      Returns:
      A cursor-based model object paging.