001 002package com.commercetools.api.models.channel; 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 results containing an array of Channel.</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 * ChannelPagedQueryResponse channelPagedQueryResponse = ChannelPagedQueryResponse.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 = ChannelPagedQueryResponseImpl.class) 036public interface ChannelPagedQueryResponse extends com.commercetools.api.models.ResourcePagedQueryResponse<Channel> { 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>Channels matching the query.</p> 072 * @return results 073 */ 074 @NotNull 075 @Valid 076 @JsonProperty("results") 077 public List<Channel> 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>Channels matching the query.</p> 109 * @param results values to be set 110 */ 111 112 @JsonIgnore 113 public void setResults(final Channel... results); 114 115 /** 116 * <p>Channels matching the query.</p> 117 * @param results values to be set 118 */ 119 120 public void setResults(final List<Channel> results); 121 122 /** 123 * factory method 124 * @return instance of ChannelPagedQueryResponse 125 */ 126 public static ChannelPagedQueryResponse of() { 127 return new ChannelPagedQueryResponseImpl(); 128 } 129 130 /** 131 * factory method to create a shallow copy ChannelPagedQueryResponse 132 * @param template instance to be copied 133 * @return copy instance 134 */ 135 public static ChannelPagedQueryResponse of(final ChannelPagedQueryResponse template) { 136 ChannelPagedQueryResponseImpl instance = new ChannelPagedQueryResponseImpl(); 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 ChannelPagedQueryResponse 147 * @param template instance to be copied 148 * @return copy instance 149 */ 150 @Nullable 151 public static ChannelPagedQueryResponse deepCopy(@Nullable final ChannelPagedQueryResponse template) { 152 if (template == null) { 153 return null; 154 } 155 ChannelPagedQueryResponseImpl instance = new ChannelPagedQueryResponseImpl(); 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.channel.Channel::deepCopy) 163 .collect(Collectors.toList())) 164 .orElse(null)); 165 return instance; 166 } 167 168 /** 169 * builder factory method for ChannelPagedQueryResponse 170 * @return builder 171 */ 172 public static ChannelPagedQueryResponseBuilder builder() { 173 return ChannelPagedQueryResponseBuilder.of(); 174 } 175 176 /** 177 * create builder for ChannelPagedQueryResponse instance 178 * @param template instance with prefilled values for the builder 179 * @return builder 180 */ 181 public static ChannelPagedQueryResponseBuilder builder(final ChannelPagedQueryResponse template) { 182 return ChannelPagedQueryResponseBuilder.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 withChannelPagedQueryResponse(Function<ChannelPagedQueryResponse, 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<ChannelPagedQueryResponse> typeReference() { 200 return new com.fasterxml.jackson.core.type.TypeReference<ChannelPagedQueryResponse>() { 201 @Override 202 public String toString() { 203 return "TypeReference<ChannelPagedQueryResponse>"; 204 } 205 }; 206 } 207}