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

com.contentful.java.cda.CDAAsset Maven / Gradle / Ivy

There is a newer version: 9.1.0
Show newest version
package com.contentful.java.cda;

import java.util.Map;

/** Represents a single asset. */
public class CDAAsset extends LocalizedResource {
  /** Title */
  public String title() {
    return getField("title");
  }

  /** Url */
  public String url() {
    return fileField("url");
  }

  /** Mime-type */
  public String mimeType() {
    return fileField("contentType");
  }

  /** Helper method to extract a field from the {@code file} map. */
  @SuppressWarnings("unchecked")
  public  T fileField(String key) {
    T result = null;
    Map file = getField("file");
    if (file != null) {
      result = (T) file.get(key);
    }
    return result;
  }

  /**
   * Return a string, showing the id and title.
   * @return a human readable string
   */
  @Override public String toString() {
    return "CDAAsset{" +
        "id='" + id() + '\'' +
        ", title='" + title() + '\'' +
        '}';
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy