001
002package com.commercetools.api.models.discount_code;
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 * DiscountCodePagedQueryResponseBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     DiscountCodePagedQueryResponse discountCodePagedQueryResponse = DiscountCodePagedQueryResponse.builder()
019 *             .limit(0.3)
020 *             .offset(0.3)
021 *             .count(0.3)
022 *             .plusResults(resultsBuilder -> resultsBuilder)
023 *             .build()
024 * </code></pre>
025 * </div>
026 */
027@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
028public class DiscountCodePagedQueryResponseBuilder implements Builder<DiscountCodePagedQueryResponse> {
029
030    private Long limit;
031
032    private Long offset;
033
034    private Long count;
035
036    @Nullable
037    private Long total;
038
039    private java.util.List<com.commercetools.api.models.discount_code.DiscountCode> results;
040
041    /**
042     *  <p>Number of results requested.</p>
043     * @param limit value to be set
044     * @return Builder
045     */
046
047    public DiscountCodePagedQueryResponseBuilder limit(final Long limit) {
048        this.limit = limit;
049        return this;
050    }
051
052    /**
053     *  <p>Number of elements skipped.</p>
054     * @param offset value to be set
055     * @return Builder
056     */
057
058    public DiscountCodePagedQueryResponseBuilder offset(final Long offset) {
059        this.offset = offset;
060        return this;
061    }
062
063    /**
064     *  <p>Actual number of results returned.</p>
065     * @param count value to be set
066     * @return Builder
067     */
068
069    public DiscountCodePagedQueryResponseBuilder count(final Long count) {
070        this.count = count;
071        return this;
072    }
073
074    /**
075     *  <p>Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter <code>withTotal=false</code>. When the results are filtered with a Query Predicate, <code>total</code> is subject to a limit.</p>
076     * @param total value to be set
077     * @return Builder
078     */
079
080    public DiscountCodePagedQueryResponseBuilder total(@Nullable final Long total) {
081        this.total = total;
082        return this;
083    }
084
085    /**
086     *  <p>DiscountCodes matching the query.</p>
087     * @param results value to be set
088     * @return Builder
089     */
090
091    public DiscountCodePagedQueryResponseBuilder results(
092            final com.commercetools.api.models.discount_code.DiscountCode... results) {
093        this.results = new ArrayList<>(Arrays.asList(results));
094        return this;
095    }
096
097    /**
098     *  <p>DiscountCodes matching the query.</p>
099     * @param results value to be set
100     * @return Builder
101     */
102
103    public DiscountCodePagedQueryResponseBuilder results(
104            final java.util.List<com.commercetools.api.models.discount_code.DiscountCode> results) {
105        this.results = results;
106        return this;
107    }
108
109    /**
110     *  <p>DiscountCodes matching the query.</p>
111     * @param results value to be set
112     * @return Builder
113     */
114
115    public DiscountCodePagedQueryResponseBuilder plusResults(
116            final com.commercetools.api.models.discount_code.DiscountCode... results) {
117        if (this.results == null) {
118            this.results = new ArrayList<>();
119        }
120        this.results.addAll(Arrays.asList(results));
121        return this;
122    }
123
124    /**
125     *  <p>DiscountCodes matching the query.</p>
126     * @param builder function to build the results value
127     * @return Builder
128     */
129
130    public DiscountCodePagedQueryResponseBuilder plusResults(
131            Function<com.commercetools.api.models.discount_code.DiscountCodeBuilder, com.commercetools.api.models.discount_code.DiscountCodeBuilder> builder) {
132        if (this.results == null) {
133            this.results = new ArrayList<>();
134        }
135        this.results.add(builder.apply(com.commercetools.api.models.discount_code.DiscountCodeBuilder.of()).build());
136        return this;
137    }
138
139    /**
140     *  <p>DiscountCodes matching the query.</p>
141     * @param builder function to build the results value
142     * @return Builder
143     */
144
145    public DiscountCodePagedQueryResponseBuilder withResults(
146            Function<com.commercetools.api.models.discount_code.DiscountCodeBuilder, com.commercetools.api.models.discount_code.DiscountCodeBuilder> builder) {
147        this.results = new ArrayList<>();
148        this.results.add(builder.apply(com.commercetools.api.models.discount_code.DiscountCodeBuilder.of()).build());
149        return this;
150    }
151
152    /**
153     *  <p>DiscountCodes matching the query.</p>
154     * @param builder function to build the results value
155     * @return Builder
156     */
157
158    public DiscountCodePagedQueryResponseBuilder addResults(
159            Function<com.commercetools.api.models.discount_code.DiscountCodeBuilder, com.commercetools.api.models.discount_code.DiscountCode> builder) {
160        return plusResults(builder.apply(com.commercetools.api.models.discount_code.DiscountCodeBuilder.of()));
161    }
162
163    /**
164     *  <p>DiscountCodes matching the query.</p>
165     * @param builder function to build the results value
166     * @return Builder
167     */
168
169    public DiscountCodePagedQueryResponseBuilder setResults(
170            Function<com.commercetools.api.models.discount_code.DiscountCodeBuilder, com.commercetools.api.models.discount_code.DiscountCode> builder) {
171        return results(builder.apply(com.commercetools.api.models.discount_code.DiscountCodeBuilder.of()));
172    }
173
174    /**
175     *  <p>Number of results requested.</p>
176     * @return limit
177     */
178
179    public Long getLimit() {
180        return this.limit;
181    }
182
183    /**
184     *  <p>Number of elements skipped.</p>
185     * @return offset
186     */
187
188    public Long getOffset() {
189        return this.offset;
190    }
191
192    /**
193     *  <p>Actual number of results returned.</p>
194     * @return count
195     */
196
197    public Long getCount() {
198        return this.count;
199    }
200
201    /**
202     *  <p>Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter <code>withTotal=false</code>. When the results are filtered with a Query Predicate, <code>total</code> is subject to a limit.</p>
203     * @return total
204     */
205
206    @Nullable
207    public Long getTotal() {
208        return this.total;
209    }
210
211    /**
212     *  <p>DiscountCodes matching the query.</p>
213     * @return results
214     */
215
216    public java.util.List<com.commercetools.api.models.discount_code.DiscountCode> getResults() {
217        return this.results;
218    }
219
220    /**
221     * builds DiscountCodePagedQueryResponse with checking for non-null required values
222     * @return DiscountCodePagedQueryResponse
223     */
224    public DiscountCodePagedQueryResponse build() {
225        Objects.requireNonNull(limit, DiscountCodePagedQueryResponse.class + ": limit is missing");
226        Objects.requireNonNull(offset, DiscountCodePagedQueryResponse.class + ": offset is missing");
227        Objects.requireNonNull(count, DiscountCodePagedQueryResponse.class + ": count is missing");
228        Objects.requireNonNull(results, DiscountCodePagedQueryResponse.class + ": results is missing");
229        return new DiscountCodePagedQueryResponseImpl(limit, offset, count, total, results);
230    }
231
232    /**
233     * builds DiscountCodePagedQueryResponse without checking for non-null required values
234     * @return DiscountCodePagedQueryResponse
235     */
236    public DiscountCodePagedQueryResponse buildUnchecked() {
237        return new DiscountCodePagedQueryResponseImpl(limit, offset, count, total, results);
238    }
239
240    /**
241     * factory method for an instance of DiscountCodePagedQueryResponseBuilder
242     * @return builder
243     */
244    public static DiscountCodePagedQueryResponseBuilder of() {
245        return new DiscountCodePagedQueryResponseBuilder();
246    }
247
248    /**
249     * create builder for DiscountCodePagedQueryResponse instance
250     * @param template instance with prefilled values for the builder
251     * @return builder
252     */
253    public static DiscountCodePagedQueryResponseBuilder of(final DiscountCodePagedQueryResponse template) {
254        DiscountCodePagedQueryResponseBuilder builder = new DiscountCodePagedQueryResponseBuilder();
255        builder.limit = template.getLimit();
256        builder.offset = template.getOffset();
257        builder.count = template.getCount();
258        builder.total = template.getTotal();
259        builder.results = template.getResults();
260        return builder;
261    }
262
263}