public interface Image

An Image uploaded to commercetools Composable Commerce is stored in a Content Delivery Network and it's available in several pre-defined sizes. If you already have an image stored on an external service, you can save the URL when creating a new product or adding a variant, or you can add it later.


Example to create an instance using the builder pattern

     Image image = Image.builder()
             .url("{url}")
             .dimensions(dimensionsBuilder -> dimensionsBuilder)
             .build()
 
  • Method Summary

    Modifier and Type
    Method
    Description
    builder factory method for Image
    builder(Image template)
    create builder for Image instance
    static Image
    deepCopy(Image template)
    factory method to create a deep copy of Image
    @NotNull @Valid AssetDimensions
    Dimensions of the original image.
    Custom label that can be used, for example, as an image description.
    @NotNull String
    URL of the image in its original size.
    static Image
    of()
    factory method
    static Image
    of(Image template)
    factory method to create a shallow copy Image
    void
    Dimensions of the original image.
    void
    Custom label that can be used, for example, as an image description.
    void
    URL of the image in its original size.
    static com.fasterxml.jackson.core.type.TypeReference<Image>
    gives a TypeReference for usage with Jackson DataBind
    default <T> T
    accessor map function
  • Method Details

    • getUrl

      @NotNull @NotNull String getUrl()

      URL of the image in its original size. The URL must be unique within a single variant. It can be used to obtain the image in different sizes.

      Returns:
      url
    • getDimensions

      @NotNull @Valid @NotNull @Valid AssetDimensions getDimensions()

      Dimensions of the original image. This can be used by your application, for example, to determine whether the image is large enough to display a zoom view.

      Returns:
      dimensions
    • getLabel

      String getLabel()

      Custom label that can be used, for example, as an image description.

      Returns:
      label
    • setUrl

      void setUrl(String url)

      URL of the image in its original size. The URL must be unique within a single variant. It can be used to obtain the image in different sizes.

      Parameters:
      url - value to be set
    • setDimensions

      void setDimensions(AssetDimensions dimensions)

      Dimensions of the original image. This can be used by your application, for example, to determine whether the image is large enough to display a zoom view.

      Parameters:
      dimensions - value to be set
    • setLabel

      void setLabel(String label)

      Custom label that can be used, for example, as an image description.

      Parameters:
      label - value to be set
    • of

      static Image of()
      factory method
      Returns:
      instance of Image
    • of

      static Image of(Image template)
      factory method to create a shallow copy Image
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      @Nullable static Image deepCopy(@Nullable Image template)
      factory method to create a deep copy of Image
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static ImageBuilder builder()
      builder factory method for Image
      Returns:
      builder
    • builder

      static ImageBuilder builder(Image template)
      create builder for Image instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withImage

      default <T> T withImage(Function<Image,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<Image> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference