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