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