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