001
002package com.commercetools.api.models.api_client;
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.fasterxml.jackson.annotation.*;
014import com.fasterxml.jackson.databind.annotation.*;
015
016import io.vrap.rmf.base.client.utils.Generated;
017
018/**
019 *  <p>PagedQueryResult with <code>results</code> containing an array of APIClient.</p>
020 *
021 * <hr>
022 * Example to create an instance using the builder pattern
023 * <div class=code-example>
024 * <pre><code class='java'>
025 *     ApiClientPagedQueryResponse apiClientPagedQueryResponse = ApiClientPagedQueryResponse.builder()
026 *             .limit(0.3)
027 *             .offset(0.3)
028 *             .count(0.3)
029 *             .plusResults(resultsBuilder -> resultsBuilder)
030 *             .build()
031 * </code></pre>
032 * </div>
033 */
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035@JsonDeserialize(as = ApiClientPagedQueryResponseImpl.class)
036public interface ApiClientPagedQueryResponse
037        extends com.commercetools.api.models.ResourcePagedQueryResponse<ApiClient> {
038
039    /**
040     *  <p>Number of results requested.</p>
041     * @return limit
042     */
043    @NotNull
044    @JsonProperty("limit")
045    public Long getLimit();
046
047    /**
048     *  <p>Number of elements skipped.</p>
049     * @return offset
050     */
051    @NotNull
052    @JsonProperty("offset")
053    public Long getOffset();
054
055    /**
056     *  <p>Actual number of results returned.</p>
057     * @return count
058     */
059    @NotNull
060    @JsonProperty("count")
061    public Long getCount();
062
063    /**
064     *  <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>
065     * @return total
066     */
067
068    @JsonProperty("total")
069    public Long getTotal();
070
071    /**
072     *  <p>APIClients matching the query.</p>
073     * @return results
074     */
075    @NotNull
076    @Valid
077    @JsonProperty("results")
078    public List<ApiClient> getResults();
079
080    /**
081     *  <p>Number of results requested.</p>
082     * @param limit value to be set
083     */
084
085    public void setLimit(final Long limit);
086
087    /**
088     *  <p>Number of elements skipped.</p>
089     * @param offset value to be set
090     */
091
092    public void setOffset(final Long offset);
093
094    /**
095     *  <p>Actual number of results returned.</p>
096     * @param count value to be set
097     */
098
099    public void setCount(final Long count);
100
101    /**
102     *  <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>
103     * @param total value to be set
104     */
105
106    public void setTotal(final Long total);
107
108    /**
109     *  <p>APIClients matching the query.</p>
110     * @param results values to be set
111     */
112
113    @JsonIgnore
114    public void setResults(final ApiClient... results);
115
116    /**
117     *  <p>APIClients matching the query.</p>
118     * @param results values to be set
119     */
120
121    public void setResults(final List<ApiClient> results);
122
123    /**
124     * factory method
125     * @return instance of ApiClientPagedQueryResponse
126     */
127    public static ApiClientPagedQueryResponse of() {
128        return new ApiClientPagedQueryResponseImpl();
129    }
130
131    /**
132     * factory method to create a shallow copy ApiClientPagedQueryResponse
133     * @param template instance to be copied
134     * @return copy instance
135     */
136    public static ApiClientPagedQueryResponse of(final ApiClientPagedQueryResponse template) {
137        ApiClientPagedQueryResponseImpl instance = new ApiClientPagedQueryResponseImpl();
138        instance.setLimit(template.getLimit());
139        instance.setOffset(template.getOffset());
140        instance.setCount(template.getCount());
141        instance.setTotal(template.getTotal());
142        instance.setResults(template.getResults());
143        return instance;
144    }
145
146    /**
147     * factory method to create a deep copy of ApiClientPagedQueryResponse
148     * @param template instance to be copied
149     * @return copy instance
150     */
151    @Nullable
152    public static ApiClientPagedQueryResponse deepCopy(@Nullable final ApiClientPagedQueryResponse template) {
153        if (template == null) {
154            return null;
155        }
156        ApiClientPagedQueryResponseImpl instance = new ApiClientPagedQueryResponseImpl();
157        instance.setLimit(template.getLimit());
158        instance.setOffset(template.getOffset());
159        instance.setCount(template.getCount());
160        instance.setTotal(template.getTotal());
161        instance.setResults(Optional.ofNullable(template.getResults())
162                .map(t -> t.stream()
163                        .map(com.commercetools.api.models.api_client.ApiClient::deepCopy)
164                        .collect(Collectors.toList()))
165                .orElse(null));
166        return instance;
167    }
168
169    /**
170     * builder factory method for ApiClientPagedQueryResponse
171     * @return builder
172     */
173    public static ApiClientPagedQueryResponseBuilder builder() {
174        return ApiClientPagedQueryResponseBuilder.of();
175    }
176
177    /**
178     * create builder for ApiClientPagedQueryResponse instance
179     * @param template instance with prefilled values for the builder
180     * @return builder
181     */
182    public static ApiClientPagedQueryResponseBuilder builder(final ApiClientPagedQueryResponse template) {
183        return ApiClientPagedQueryResponseBuilder.of(template);
184    }
185
186    /**
187     * accessor map function
188     * @param <T> mapped type
189     * @param helper function to map the object
190     * @return mapped value
191     */
192    default <T> T withApiClientPagedQueryResponse(Function<ApiClientPagedQueryResponse, T> helper) {
193        return helper.apply(this);
194    }
195
196    /**
197     * gives a TypeReference for usage with Jackson DataBind
198     * @return TypeReference
199     */
200    public static com.fasterxml.jackson.core.type.TypeReference<ApiClientPagedQueryResponse> typeReference() {
201        return new com.fasterxml.jackson.core.type.TypeReference<ApiClientPagedQueryResponse>() {
202            @Override
203            public String toString() {
204                return "TypeReference<ApiClientPagedQueryResponse>";
205            }
206        };
207    }
208}