001
002package com.commercetools.api.models.product;
003
004import java.util.*;
005import java.util.function.Function;
006
007import javax.annotation.Nullable;
008
009import io.vrap.rmf.base.client.Builder;
010import io.vrap.rmf.base.client.utils.Generated;
011
012/**
013 * ProductProjectionPagedSearchResponseBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     ProductProjectionPagedSearchResponse productProjectionPagedSearchResponse = ProductProjectionPagedSearchResponse.builder()
019 *             .limit(0.3)
020 *             .count(0.3)
021 *             .offset(0.3)
022 *             .plusResults(resultsBuilder -> resultsBuilder)
023 *             .facets(facetsBuilder -> facetsBuilder)
024 *             .build()
025 * </code></pre>
026 * </div>
027 */
028@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
029public class ProductProjectionPagedSearchResponseBuilder implements Builder<ProductProjectionPagedSearchResponse> {
030
031    private Long limit;
032
033    private Long count;
034
035    @Nullable
036    private Long total;
037
038    private Long offset;
039
040    private java.util.List<com.commercetools.api.models.product.ProductProjection> results;
041
042    private com.commercetools.api.models.product.FacetResults facets;
043
044    /**
045     *  <p>Number of results requested.</p>
046     * @param limit value to be set
047     * @return Builder
048     */
049
050    public ProductProjectionPagedSearchResponseBuilder limit(final Long limit) {
051        this.limit = limit;
052        return this;
053    }
054
055    /**
056     * set the value to the count
057     * @param count value to be set
058     * @return Builder
059     */
060
061    public ProductProjectionPagedSearchResponseBuilder count(final Long count) {
062        this.count = count;
063        return this;
064    }
065
066    /**
067     * set the value to the total
068     * @param total value to be set
069     * @return Builder
070     */
071
072    public ProductProjectionPagedSearchResponseBuilder total(@Nullable final Long total) {
073        this.total = total;
074        return this;
075    }
076
077    /**
078     *  <p>Number of elements skipped.</p>
079     * @param offset value to be set
080     * @return Builder
081     */
082
083    public ProductProjectionPagedSearchResponseBuilder offset(final Long offset) {
084        this.offset = offset;
085        return this;
086    }
087
088    /**
089     * set values to the results
090     * @param results value to be set
091     * @return Builder
092     */
093
094    public ProductProjectionPagedSearchResponseBuilder results(
095            final com.commercetools.api.models.product.ProductProjection... results) {
096        this.results = new ArrayList<>(Arrays.asList(results));
097        return this;
098    }
099
100    /**
101     * set value to the results
102     * @param results value to be set
103     * @return Builder
104     */
105
106    public ProductProjectionPagedSearchResponseBuilder results(
107            final java.util.List<com.commercetools.api.models.product.ProductProjection> results) {
108        this.results = results;
109        return this;
110    }
111
112    /**
113     * add values to the results
114     * @param results value to be set
115     * @return Builder
116     */
117
118    public ProductProjectionPagedSearchResponseBuilder plusResults(
119            final com.commercetools.api.models.product.ProductProjection... results) {
120        if (this.results == null) {
121            this.results = new ArrayList<>();
122        }
123        this.results.addAll(Arrays.asList(results));
124        return this;
125    }
126
127    /**
128     * add the value to the results using the builder function
129     * @param builder function to build the results value
130     * @return Builder
131     */
132
133    public ProductProjectionPagedSearchResponseBuilder plusResults(
134            Function<com.commercetools.api.models.product.ProductProjectionBuilder, com.commercetools.api.models.product.ProductProjectionBuilder> builder) {
135        if (this.results == null) {
136            this.results = new ArrayList<>();
137        }
138        this.results.add(builder.apply(com.commercetools.api.models.product.ProductProjectionBuilder.of()).build());
139        return this;
140    }
141
142    /**
143     * set the value to the results using the builder function
144     * @param builder function to build the results value
145     * @return Builder
146     */
147
148    public ProductProjectionPagedSearchResponseBuilder withResults(
149            Function<com.commercetools.api.models.product.ProductProjectionBuilder, com.commercetools.api.models.product.ProductProjectionBuilder> builder) {
150        this.results = new ArrayList<>();
151        this.results.add(builder.apply(com.commercetools.api.models.product.ProductProjectionBuilder.of()).build());
152        return this;
153    }
154
155    /**
156     * add the value to the results using the builder function
157     * @param builder function to build the results value
158     * @return Builder
159     */
160
161    public ProductProjectionPagedSearchResponseBuilder addResults(
162            Function<com.commercetools.api.models.product.ProductProjectionBuilder, com.commercetools.api.models.product.ProductProjection> builder) {
163        return plusResults(builder.apply(com.commercetools.api.models.product.ProductProjectionBuilder.of()));
164    }
165
166    /**
167     * set the value to the results using the builder function
168     * @param builder function to build the results value
169     * @return Builder
170     */
171
172    public ProductProjectionPagedSearchResponseBuilder setResults(
173            Function<com.commercetools.api.models.product.ProductProjectionBuilder, com.commercetools.api.models.product.ProductProjection> builder) {
174        return results(builder.apply(com.commercetools.api.models.product.ProductProjectionBuilder.of()));
175    }
176
177    /**
178     * set the value to the facets using the builder function
179     * @param builder function to build the facets value
180     * @return Builder
181     */
182
183    public ProductProjectionPagedSearchResponseBuilder facets(
184            Function<com.commercetools.api.models.product.FacetResultsBuilder, com.commercetools.api.models.product.FacetResultsBuilder> builder) {
185        this.facets = builder.apply(com.commercetools.api.models.product.FacetResultsBuilder.of()).build();
186        return this;
187    }
188
189    /**
190     * set the value to the facets using the builder function
191     * @param builder function to build the facets value
192     * @return Builder
193     */
194
195    public ProductProjectionPagedSearchResponseBuilder withFacets(
196            Function<com.commercetools.api.models.product.FacetResultsBuilder, com.commercetools.api.models.product.FacetResults> builder) {
197        this.facets = builder.apply(com.commercetools.api.models.product.FacetResultsBuilder.of());
198        return this;
199    }
200
201    /**
202     * set the value to the facets
203     * @param facets value to be set
204     * @return Builder
205     */
206
207    public ProductProjectionPagedSearchResponseBuilder facets(
208            final com.commercetools.api.models.product.FacetResults facets) {
209        this.facets = facets;
210        return this;
211    }
212
213    /**
214     *  <p>Number of results requested.</p>
215     * @return limit
216     */
217
218    public Long getLimit() {
219        return this.limit;
220    }
221
222    /**
223     * value of count}
224     * @return count
225     */
226
227    public Long getCount() {
228        return this.count;
229    }
230
231    /**
232     * value of total}
233     * @return total
234     */
235
236    @Nullable
237    public Long getTotal() {
238        return this.total;
239    }
240
241    /**
242     *  <p>Number of elements skipped.</p>
243     * @return offset
244     */
245
246    public Long getOffset() {
247        return this.offset;
248    }
249
250    /**
251     * value of results}
252     * @return results
253     */
254
255    public java.util.List<com.commercetools.api.models.product.ProductProjection> getResults() {
256        return this.results;
257    }
258
259    /**
260     * value of facets}
261     * @return facets
262     */
263
264    public com.commercetools.api.models.product.FacetResults getFacets() {
265        return this.facets;
266    }
267
268    /**
269     * builds ProductProjectionPagedSearchResponse with checking for non-null required values
270     * @return ProductProjectionPagedSearchResponse
271     */
272    public ProductProjectionPagedSearchResponse build() {
273        Objects.requireNonNull(limit, ProductProjectionPagedSearchResponse.class + ": limit is missing");
274        Objects.requireNonNull(count, ProductProjectionPagedSearchResponse.class + ": count is missing");
275        Objects.requireNonNull(offset, ProductProjectionPagedSearchResponse.class + ": offset is missing");
276        Objects.requireNonNull(results, ProductProjectionPagedSearchResponse.class + ": results is missing");
277        Objects.requireNonNull(facets, ProductProjectionPagedSearchResponse.class + ": facets is missing");
278        return new ProductProjectionPagedSearchResponseImpl(limit, count, total, offset, results, facets);
279    }
280
281    /**
282     * builds ProductProjectionPagedSearchResponse without checking for non-null required values
283     * @return ProductProjectionPagedSearchResponse
284     */
285    public ProductProjectionPagedSearchResponse buildUnchecked() {
286        return new ProductProjectionPagedSearchResponseImpl(limit, count, total, offset, results, facets);
287    }
288
289    /**
290     * factory method for an instance of ProductProjectionPagedSearchResponseBuilder
291     * @return builder
292     */
293    public static ProductProjectionPagedSearchResponseBuilder of() {
294        return new ProductProjectionPagedSearchResponseBuilder();
295    }
296
297    /**
298     * create builder for ProductProjectionPagedSearchResponse instance
299     * @param template instance with prefilled values for the builder
300     * @return builder
301     */
302    public static ProductProjectionPagedSearchResponseBuilder of(final ProductProjectionPagedSearchResponse template) {
303        ProductProjectionPagedSearchResponseBuilder builder = new ProductProjectionPagedSearchResponseBuilder();
304        builder.limit = template.getLimit();
305        builder.count = template.getCount();
306        builder.total = template.getTotal();
307        builder.offset = template.getOffset();
308        builder.results = template.getResults();
309        builder.facets = template.getFacets();
310        return builder;
311    }
312
313}