001
002package com.commercetools.ml.models.image_search;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007import java.util.stream.Collectors;
008
009import javax.annotation.Nullable;
010import javax.validation.Valid;
011import javax.validation.constraints.NotNull;
012
013import com.commercetools.ml.models.common.ProductVariant;
014import com.fasterxml.jackson.annotation.*;
015import com.fasterxml.jackson.databind.annotation.*;
016
017import io.vrap.rmf.base.client.utils.Generated;
018
019/**
020 *  <p>An image URL and the product variants it is contained in. If no matching images are found, ResultItem is not present.</p>
021 *
022 * <hr>
023 * Example to create an instance using the builder pattern
024 * <div class=code-example>
025 * <pre><code class='java'>
026 *     ResultItem resultItem = ResultItem.builder()
027 *             .imageUrl("{imageUrl}")
028 *             .plusProductVariants(productVariantsBuilder -> productVariantsBuilder)
029 *             .build()
030 * </code></pre>
031 * </div>
032 */
033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
034@JsonDeserialize(as = ResultItemImpl.class)
035public interface ResultItem {
036
037    /**
038     *  <p>The URL of the image.</p>
039     * @return imageUrl
040     */
041    @NotNull
042    @JsonProperty("imageUrl")
043    public String getImageUrl();
044
045    /**
046     *  <p>An array of product variants containing the image URL.</p>
047     * @return productVariants
048     */
049    @NotNull
050    @Valid
051    @JsonProperty("productVariants")
052    public List<ProductVariant> getProductVariants();
053
054    /**
055     *  <p>The URL of the image.</p>
056     * @param imageUrl value to be set
057     */
058
059    public void setImageUrl(final String imageUrl);
060
061    /**
062     *  <p>An array of product variants containing the image URL.</p>
063     * @param productVariants values to be set
064     */
065
066    @JsonIgnore
067    public void setProductVariants(final ProductVariant... productVariants);
068
069    /**
070     *  <p>An array of product variants containing the image URL.</p>
071     * @param productVariants values to be set
072     */
073
074    public void setProductVariants(final List<ProductVariant> productVariants);
075
076    /**
077     * factory method
078     * @return instance of ResultItem
079     */
080    public static ResultItem of() {
081        return new ResultItemImpl();
082    }
083
084    /**
085     * factory method to create a shallow copy ResultItem
086     * @param template instance to be copied
087     * @return copy instance
088     */
089    public static ResultItem of(final ResultItem template) {
090        ResultItemImpl instance = new ResultItemImpl();
091        instance.setImageUrl(template.getImageUrl());
092        instance.setProductVariants(template.getProductVariants());
093        return instance;
094    }
095
096    /**
097     * factory method to create a deep copy of ResultItem
098     * @param template instance to be copied
099     * @return copy instance
100     */
101    @Nullable
102    public static ResultItem deepCopy(@Nullable final ResultItem template) {
103        if (template == null) {
104            return null;
105        }
106        ResultItemImpl instance = new ResultItemImpl();
107        instance.setImageUrl(template.getImageUrl());
108        instance.setProductVariants(Optional.ofNullable(template.getProductVariants())
109                .map(t -> t.stream()
110                        .map(com.commercetools.ml.models.common.ProductVariant::deepCopy)
111                        .collect(Collectors.toList()))
112                .orElse(null));
113        return instance;
114    }
115
116    /**
117     * builder factory method for ResultItem
118     * @return builder
119     */
120    public static ResultItemBuilder builder() {
121        return ResultItemBuilder.of();
122    }
123
124    /**
125     * create builder for ResultItem instance
126     * @param template instance with prefilled values for the builder
127     * @return builder
128     */
129    public static ResultItemBuilder builder(final ResultItem template) {
130        return ResultItemBuilder.of(template);
131    }
132
133    /**
134     * accessor map function
135     * @param <T> mapped type
136     * @param helper function to map the object
137     * @return mapped value
138     */
139    default <T> T withResultItem(Function<ResultItem, T> helper) {
140        return helper.apply(this);
141    }
142
143    /**
144     * gives a TypeReference for usage with Jackson DataBind
145     * @return TypeReference
146     */
147    public static com.fasterxml.jackson.core.type.TypeReference<ResultItem> typeReference() {
148        return new com.fasterxml.jackson.core.type.TypeReference<ResultItem>() {
149            @Override
150            public String toString() {
151                return "TypeReference<ResultItem>";
152            }
153        };
154    }
155}