001 002package com.commercetools.api.models.business_unit; 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 * BusinessUnitPagedQueryResponseBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * BusinessUnitPagedQueryResponse businessUnitPagedQueryResponse = BusinessUnitPagedQueryResponse.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 BusinessUnitPagedQueryResponseBuilder implements Builder<BusinessUnitPagedQueryResponse> { 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.business_unit.BusinessUnit> results; 040 041 /** 042 * <p>Number of requested results.</p> 043 * @param limit value to be set 044 * @return Builder 045 */ 046 047 public BusinessUnitPagedQueryResponseBuilder 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 BusinessUnitPagedQueryResponseBuilder 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 BusinessUnitPagedQueryResponseBuilder count(final Long count) { 070 this.count = count; 071 return this; 072 } 073 074 /** 075 * <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> 076 * @param total value to be set 077 * @return Builder 078 */ 079 080 public BusinessUnitPagedQueryResponseBuilder total(@Nullable final Long total) { 081 this.total = total; 082 return this; 083 } 084 085 /** 086 * <p>BusinessUnits matching the query.</p> 087 * @param results value to be set 088 * @return Builder 089 */ 090 091 public BusinessUnitPagedQueryResponseBuilder results( 092 final com.commercetools.api.models.business_unit.BusinessUnit... results) { 093 this.results = new ArrayList<>(Arrays.asList(results)); 094 return this; 095 } 096 097 /** 098 * <p>BusinessUnits matching the query.</p> 099 * @param results value to be set 100 * @return Builder 101 */ 102 103 public BusinessUnitPagedQueryResponseBuilder results( 104 final java.util.List<com.commercetools.api.models.business_unit.BusinessUnit> results) { 105 this.results = results; 106 return this; 107 } 108 109 /** 110 * <p>BusinessUnits matching the query.</p> 111 * @param results value to be set 112 * @return Builder 113 */ 114 115 public BusinessUnitPagedQueryResponseBuilder plusResults( 116 final com.commercetools.api.models.business_unit.BusinessUnit... 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>BusinessUnits matching the query.</p> 126 * @param builder function to build the results value 127 * @return Builder 128 */ 129 130 public BusinessUnitPagedQueryResponseBuilder plusResults( 131 Function<com.commercetools.api.models.business_unit.BusinessUnitBuilder, Builder<? extends com.commercetools.api.models.business_unit.BusinessUnit>> builder) { 132 if (this.results == null) { 133 this.results = new ArrayList<>(); 134 } 135 this.results.add(builder.apply(com.commercetools.api.models.business_unit.BusinessUnitBuilder.of()).build()); 136 return this; 137 } 138 139 /** 140 * <p>BusinessUnits matching the query.</p> 141 * @param builder function to build the results value 142 * @return Builder 143 */ 144 145 public BusinessUnitPagedQueryResponseBuilder withResults( 146 Function<com.commercetools.api.models.business_unit.BusinessUnitBuilder, Builder<? extends com.commercetools.api.models.business_unit.BusinessUnit>> builder) { 147 this.results = new ArrayList<>(); 148 this.results.add(builder.apply(com.commercetools.api.models.business_unit.BusinessUnitBuilder.of()).build()); 149 return this; 150 } 151 152 /** 153 * <p>Number of requested results.</p> 154 * @return limit 155 */ 156 157 public Long getLimit() { 158 return this.limit; 159 } 160 161 /** 162 * <p>Number of elements skipped.</p> 163 * @return offset 164 */ 165 166 public Long getOffset() { 167 return this.offset; 168 } 169 170 /** 171 * <p>Actual number of results returned.</p> 172 * @return count 173 */ 174 175 public Long getCount() { 176 return this.count; 177 } 178 179 /** 180 * <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> 181 * @return total 182 */ 183 184 @Nullable 185 public Long getTotal() { 186 return this.total; 187 } 188 189 /** 190 * <p>BusinessUnits matching the query.</p> 191 * @return results 192 */ 193 194 public java.util.List<com.commercetools.api.models.business_unit.BusinessUnit> getResults() { 195 return this.results; 196 } 197 198 /** 199 * builds BusinessUnitPagedQueryResponse with checking for non-null required values 200 * @return BusinessUnitPagedQueryResponse 201 */ 202 public BusinessUnitPagedQueryResponse build() { 203 Objects.requireNonNull(limit, BusinessUnitPagedQueryResponse.class + ": limit is missing"); 204 Objects.requireNonNull(offset, BusinessUnitPagedQueryResponse.class + ": offset is missing"); 205 Objects.requireNonNull(count, BusinessUnitPagedQueryResponse.class + ": count is missing"); 206 Objects.requireNonNull(results, BusinessUnitPagedQueryResponse.class + ": results is missing"); 207 return new BusinessUnitPagedQueryResponseImpl(limit, offset, count, total, results); 208 } 209 210 /** 211 * builds BusinessUnitPagedQueryResponse without checking for non-null required values 212 * @return BusinessUnitPagedQueryResponse 213 */ 214 public BusinessUnitPagedQueryResponse buildUnchecked() { 215 return new BusinessUnitPagedQueryResponseImpl(limit, offset, count, total, results); 216 } 217 218 /** 219 * factory method for an instance of BusinessUnitPagedQueryResponseBuilder 220 * @return builder 221 */ 222 public static BusinessUnitPagedQueryResponseBuilder of() { 223 return new BusinessUnitPagedQueryResponseBuilder(); 224 } 225 226 /** 227 * create builder for BusinessUnitPagedQueryResponse instance 228 * @param template instance with prefilled values for the builder 229 * @return builder 230 */ 231 public static BusinessUnitPagedQueryResponseBuilder of(final BusinessUnitPagedQueryResponse template) { 232 BusinessUnitPagedQueryResponseBuilder builder = new BusinessUnitPagedQueryResponseBuilder(); 233 builder.limit = template.getLimit(); 234 builder.offset = template.getOffset(); 235 builder.count = template.getCount(); 236 builder.total = template.getTotal(); 237 builder.results = template.getResults(); 238 return builder; 239 } 240 241}