001
002package com.commercetools.api.models.state;
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 State.</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 *     StatePagedQueryResponse statePagedQueryResponse = StatePagedQueryResponse.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 = StatePagedQueryResponseImpl.class)
036public interface StatePagedQueryResponse extends com.commercetools.api.models.ResourcePagedQueryResponse<State> {
037
038    /**
039     *  <p>Number of results requested.</p>
040     * @return limit
041     */
042    @NotNull
043    @JsonProperty("limit")
044    public Long getLimit();
045
046    /**
047     *  <p>Number of elements skipped.</p>
048     * @return offset
049     */
050    @NotNull
051    @JsonProperty("offset")
052    public Long getOffset();
053
054    /**
055     *  <p>Actual number of results returned.</p>
056     * @return count
057     */
058    @NotNull
059    @JsonProperty("count")
060    public Long getCount();
061
062    /**
063     *  <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>
064     * @return total
065     */
066
067    @JsonProperty("total")
068    public Long getTotal();
069
070    /**
071     *  <p>States matching the query.</p>
072     * @return results
073     */
074    @NotNull
075    @Valid
076    @JsonProperty("results")
077    public List<State> getResults();
078
079    /**
080     *  <p>Number of results requested.</p>
081     * @param limit value to be set
082     */
083
084    public void setLimit(final Long limit);
085
086    /**
087     *  <p>Number of elements skipped.</p>
088     * @param offset value to be set
089     */
090
091    public void setOffset(final Long offset);
092
093    /**
094     *  <p>Actual number of results returned.</p>
095     * @param count value to be set
096     */
097
098    public void setCount(final Long count);
099
100    /**
101     *  <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>
102     * @param total value to be set
103     */
104
105    public void setTotal(final Long total);
106
107    /**
108     *  <p>States matching the query.</p>
109     * @param results values to be set
110     */
111
112    @JsonIgnore
113    public void setResults(final State... results);
114
115    /**
116     *  <p>States matching the query.</p>
117     * @param results values to be set
118     */
119
120    public void setResults(final List<State> results);
121
122    /**
123     * factory method
124     * @return instance of StatePagedQueryResponse
125     */
126    public static StatePagedQueryResponse of() {
127        return new StatePagedQueryResponseImpl();
128    }
129
130    /**
131     * factory method to create a shallow copy StatePagedQueryResponse
132     * @param template instance to be copied
133     * @return copy instance
134     */
135    public static StatePagedQueryResponse of(final StatePagedQueryResponse template) {
136        StatePagedQueryResponseImpl instance = new StatePagedQueryResponseImpl();
137        instance.setLimit(template.getLimit());
138        instance.setOffset(template.getOffset());
139        instance.setCount(template.getCount());
140        instance.setTotal(template.getTotal());
141        instance.setResults(template.getResults());
142        return instance;
143    }
144
145    /**
146     * factory method to create a deep copy of StatePagedQueryResponse
147     * @param template instance to be copied
148     * @return copy instance
149     */
150    @Nullable
151    public static StatePagedQueryResponse deepCopy(@Nullable final StatePagedQueryResponse template) {
152        if (template == null) {
153            return null;
154        }
155        StatePagedQueryResponseImpl instance = new StatePagedQueryResponseImpl();
156        instance.setLimit(template.getLimit());
157        instance.setOffset(template.getOffset());
158        instance.setCount(template.getCount());
159        instance.setTotal(template.getTotal());
160        instance.setResults(Optional.ofNullable(template.getResults())
161                .map(t -> t.stream()
162                        .map(com.commercetools.api.models.state.State::deepCopy)
163                        .collect(Collectors.toList()))
164                .orElse(null));
165        return instance;
166    }
167
168    /**
169     * builder factory method for StatePagedQueryResponse
170     * @return builder
171     */
172    public static StatePagedQueryResponseBuilder builder() {
173        return StatePagedQueryResponseBuilder.of();
174    }
175
176    /**
177     * create builder for StatePagedQueryResponse instance
178     * @param template instance with prefilled values for the builder
179     * @return builder
180     */
181    public static StatePagedQueryResponseBuilder builder(final StatePagedQueryResponse template) {
182        return StatePagedQueryResponseBuilder.of(template);
183    }
184
185    /**
186     * accessor map function
187     * @param <T> mapped type
188     * @param helper function to map the object
189     * @return mapped value
190     */
191    default <T> T withStatePagedQueryResponse(Function<StatePagedQueryResponse, T> helper) {
192        return helper.apply(this);
193    }
194
195    /**
196     * gives a TypeReference for usage with Jackson DataBind
197     * @return TypeReference
198     */
199    public static com.fasterxml.jackson.core.type.TypeReference<StatePagedQueryResponse> typeReference() {
200        return new com.fasterxml.jackson.core.type.TypeReference<StatePagedQueryResponse>() {
201            @Override
202            public String toString() {
203                return "TypeReference<StatePagedQueryResponse>";
204            }
205        };
206    }
207}