All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.michaelthelin.spotify.model_objects.specification.ExternalUrl Maven / Gradle / Ivy

There is a newer version: 9.0.0-RC1
Show newest version
package se.michaelthelin.spotify.model_objects.specification;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import se.michaelthelin.spotify.model_objects.AbstractModelObject;

import java.util.Map;

/**
 * Retrieve information about
 * External URL objects
 * by building instances from this class.
 */
@JsonDeserialize(builder = ExternalUrl.Builder.class)
public class ExternalUrl extends AbstractModelObject {
  private final Map externalUrls;

  private ExternalUrl(final Builder builder) {
    super(builder);

    this.externalUrls = builder.externalUrls;
  }

  /**
   * Get an specific external URL from this external URLs object with the key string given below.
   *
   * @param key The type of the URL.
   * @return An external, public URL to the object.
   */
  public String get(String key) {
    return externalUrls.get(key);
  }

  /**
   * Get the external URLs from this
   * External URL object.
   * 

*

* External URL example:
* "spotify" - The Spotify URL * for the object. * * @return A {@link Map} of external public URLs to its objects. */ public Map getExternalUrls() { return externalUrls; } @Override public String toString() { return "ExternalUrl(externalUrls=" + externalUrls + ")"; } @Override public Builder builder() { return new Builder(); } /** * Builder class for building {@link ExternalUrl} instances. */ public static final class Builder extends AbstractModelObject.Builder { private Map externalUrls; /** * The external URLs setter. * * @param externalUrls A {@link Map} of external public URLs to its objects. * @return A {@link ExternalUrl.Builder}. */ public Builder setExternalUrls(Map externalUrls) { this.externalUrls = externalUrls; return this; } @Override public ExternalUrl build() { return new ExternalUrl(this); } } /** * JsonUtil class for building {@link ExternalUrl} instances. */ @SuppressWarnings("unchecked") public static final class JsonUtil extends AbstractModelObject.JsonUtil { public ExternalUrl createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } Map map = new Gson().fromJson(jsonObject, Map.class); return new ExternalUrl.Builder() .setExternalUrls(map) .build(); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy