001
002package com.commercetools.ml.models.image_search;
003
004import java.util.*;
005import java.util.function.Function;
006
007import io.vrap.rmf.base.client.Builder;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * ImageSearchResponseBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     ImageSearchResponse imageSearchResponse = ImageSearchResponse.builder()
017 *             .count(0.3)
018 *             .offset(0.3)
019 *             .total(0.3)
020 *             .plusResults(resultsBuilder -> resultsBuilder)
021 *             .build()
022 * </code></pre>
023 * </div>
024 */
025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
026public class ImageSearchResponseBuilder implements Builder<ImageSearchResponse> {
027
028    private Integer count;
029
030    private Double offset;
031
032    private Integer total;
033
034    private java.util.List<com.commercetools.ml.models.image_search.ResultItem> results;
035
036    /**
037     *  <p>The maximum number of results to return from a query.</p>
038     * @param count value to be set
039     * @return Builder
040     */
041
042    public ImageSearchResponseBuilder count(final Integer count) {
043        this.count = count;
044        return this;
045    }
046
047    /**
048     *  <p>Number of elements skipped.</p>
049     * @param offset value to be set
050     * @return Builder
051     */
052
053    public ImageSearchResponseBuilder offset(final Double offset) {
054        this.offset = offset;
055        return this;
056    }
057
058    /**
059     *  <p>The total number of product images that were have been analyzed.</p>
060     * @param total value to be set
061     * @return Builder
062     */
063
064    public ImageSearchResponseBuilder total(final Integer total) {
065        this.total = total;
066        return this;
067    }
068
069    /**
070     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
071     * @param results value to be set
072     * @return Builder
073     */
074
075    public ImageSearchResponseBuilder results(final com.commercetools.ml.models.image_search.ResultItem... results) {
076        this.results = new ArrayList<>(Arrays.asList(results));
077        return this;
078    }
079
080    /**
081     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
082     * @param results value to be set
083     * @return Builder
084     */
085
086    public ImageSearchResponseBuilder results(
087            final java.util.List<com.commercetools.ml.models.image_search.ResultItem> results) {
088        this.results = results;
089        return this;
090    }
091
092    /**
093     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
094     * @param results value to be set
095     * @return Builder
096     */
097
098    public ImageSearchResponseBuilder plusResults(
099            final com.commercetools.ml.models.image_search.ResultItem... results) {
100        if (this.results == null) {
101            this.results = new ArrayList<>();
102        }
103        this.results.addAll(Arrays.asList(results));
104        return this;
105    }
106
107    /**
108     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
109     * @param builder function to build the results value
110     * @return Builder
111     */
112
113    public ImageSearchResponseBuilder plusResults(
114            Function<com.commercetools.ml.models.image_search.ResultItemBuilder, com.commercetools.ml.models.image_search.ResultItemBuilder> builder) {
115        if (this.results == null) {
116            this.results = new ArrayList<>();
117        }
118        this.results.add(builder.apply(com.commercetools.ml.models.image_search.ResultItemBuilder.of()).build());
119        return this;
120    }
121
122    /**
123     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
124     * @param builder function to build the results value
125     * @return Builder
126     */
127
128    public ImageSearchResponseBuilder withResults(
129            Function<com.commercetools.ml.models.image_search.ResultItemBuilder, com.commercetools.ml.models.image_search.ResultItemBuilder> builder) {
130        this.results = new ArrayList<>();
131        this.results.add(builder.apply(com.commercetools.ml.models.image_search.ResultItemBuilder.of()).build());
132        return this;
133    }
134
135    /**
136     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
137     * @param builder function to build the results value
138     * @return Builder
139     */
140
141    public ImageSearchResponseBuilder addResults(
142            Function<com.commercetools.ml.models.image_search.ResultItemBuilder, com.commercetools.ml.models.image_search.ResultItem> builder) {
143        return plusResults(builder.apply(com.commercetools.ml.models.image_search.ResultItemBuilder.of()));
144    }
145
146    /**
147     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
148     * @param builder function to build the results value
149     * @return Builder
150     */
151
152    public ImageSearchResponseBuilder setResults(
153            Function<com.commercetools.ml.models.image_search.ResultItemBuilder, com.commercetools.ml.models.image_search.ResultItem> builder) {
154        return results(builder.apply(com.commercetools.ml.models.image_search.ResultItemBuilder.of()));
155    }
156
157    /**
158     *  <p>The maximum number of results to return from a query.</p>
159     * @return count
160     */
161
162    public Integer getCount() {
163        return this.count;
164    }
165
166    /**
167     *  <p>Number of elements skipped.</p>
168     * @return offset
169     */
170
171    public Double getOffset() {
172        return this.offset;
173    }
174
175    /**
176     *  <p>The total number of product images that were have been analyzed.</p>
177     * @return total
178     */
179
180    public Integer getTotal() {
181        return this.total;
182    }
183
184    /**
185     *  <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p>
186     * @return results
187     */
188
189    public java.util.List<com.commercetools.ml.models.image_search.ResultItem> getResults() {
190        return this.results;
191    }
192
193    /**
194     * builds ImageSearchResponse with checking for non-null required values
195     * @return ImageSearchResponse
196     */
197    public ImageSearchResponse build() {
198        Objects.requireNonNull(count, ImageSearchResponse.class + ": count is missing");
199        Objects.requireNonNull(offset, ImageSearchResponse.class + ": offset is missing");
200        Objects.requireNonNull(total, ImageSearchResponse.class + ": total is missing");
201        Objects.requireNonNull(results, ImageSearchResponse.class + ": results is missing");
202        return new ImageSearchResponseImpl(count, offset, total, results);
203    }
204
205    /**
206     * builds ImageSearchResponse without checking for non-null required values
207     * @return ImageSearchResponse
208     */
209    public ImageSearchResponse buildUnchecked() {
210        return new ImageSearchResponseImpl(count, offset, total, results);
211    }
212
213    /**
214     * factory method for an instance of ImageSearchResponseBuilder
215     * @return builder
216     */
217    public static ImageSearchResponseBuilder of() {
218        return new ImageSearchResponseBuilder();
219    }
220
221    /**
222     * create builder for ImageSearchResponse instance
223     * @param template instance with prefilled values for the builder
224     * @return builder
225     */
226    public static ImageSearchResponseBuilder of(final ImageSearchResponse template) {
227        ImageSearchResponseBuilder builder = new ImageSearchResponseBuilder();
228        builder.count = template.getCount();
229        builder.offset = template.getOffset();
230        builder.total = template.getTotal();
231        builder.results = template.getResults();
232        return builder;
233    }
234
235}