001 002package com.commercetools.ml.models.general_category_recommendations; 003 004import java.util.*; 005import java.util.function.Function; 006 007import io.vrap.rmf.base.client.Builder; 008import io.vrap.rmf.base.client.utils.Generated; 009 010/** 011 * GeneralCategoryRecommendationPagedQueryResponseBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * GeneralCategoryRecommendationPagedQueryResponse generalCategoryRecommendationPagedQueryResponse = GeneralCategoryRecommendationPagedQueryResponse.builder() 017 * .count(0.3) 018 * .total(0.3) 019 * .offset(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 GeneralCategoryRecommendationPagedQueryResponseBuilder 027 implements Builder<GeneralCategoryRecommendationPagedQueryResponse> { 028 029 private Long count; 030 031 private Long total; 032 033 private Long offset; 034 035 private java.util.List<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation> results; 036 037 /** 038 * set the value to the count 039 * @param count value to be set 040 * @return Builder 041 */ 042 043 public GeneralCategoryRecommendationPagedQueryResponseBuilder count(final Long count) { 044 this.count = count; 045 return this; 046 } 047 048 /** 049 * set the value to the total 050 * @param total value to be set 051 * @return Builder 052 */ 053 054 public GeneralCategoryRecommendationPagedQueryResponseBuilder total(final Long total) { 055 this.total = total; 056 return this; 057 } 058 059 /** 060 * <p>Number of elements skipped.</p> 061 * @param offset value to be set 062 * @return Builder 063 */ 064 065 public GeneralCategoryRecommendationPagedQueryResponseBuilder offset(final Long offset) { 066 this.offset = offset; 067 return this; 068 } 069 070 /** 071 * set values to the results 072 * @param results value to be set 073 * @return Builder 074 */ 075 076 public GeneralCategoryRecommendationPagedQueryResponseBuilder results( 077 final com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation... results) { 078 this.results = new ArrayList<>(Arrays.asList(results)); 079 return this; 080 } 081 082 /** 083 * set value to the results 084 * @param results value to be set 085 * @return Builder 086 */ 087 088 public GeneralCategoryRecommendationPagedQueryResponseBuilder results( 089 final java.util.List<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation> results) { 090 this.results = results; 091 return this; 092 } 093 094 /** 095 * add values to the results 096 * @param results value to be set 097 * @return Builder 098 */ 099 100 public GeneralCategoryRecommendationPagedQueryResponseBuilder plusResults( 101 final com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation... results) { 102 if (this.results == null) { 103 this.results = new ArrayList<>(); 104 } 105 this.results.addAll(Arrays.asList(results)); 106 return this; 107 } 108 109 /** 110 * add the value to the results using the builder function 111 * @param builder function to build the results value 112 * @return Builder 113 */ 114 115 public GeneralCategoryRecommendationPagedQueryResponseBuilder plusResults( 116 Function<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder, com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder> builder) { 117 if (this.results == null) { 118 this.results = new ArrayList<>(); 119 } 120 this.results.add(builder 121 .apply(com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder 122 .of()) 123 .build()); 124 return this; 125 } 126 127 /** 128 * set the value to the results using the builder function 129 * @param builder function to build the results value 130 * @return Builder 131 */ 132 133 public GeneralCategoryRecommendationPagedQueryResponseBuilder withResults( 134 Function<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder, com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder> builder) { 135 this.results = new ArrayList<>(); 136 this.results.add(builder 137 .apply(com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder 138 .of()) 139 .build()); 140 return this; 141 } 142 143 /** 144 * add the value to the results using the builder function 145 * @param builder function to build the results value 146 * @return Builder 147 */ 148 149 public GeneralCategoryRecommendationPagedQueryResponseBuilder addResults( 150 Function<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder, com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation> builder) { 151 return plusResults(builder.apply( 152 com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder.of())); 153 } 154 155 /** 156 * set the value to the results using the builder function 157 * @param builder function to build the results value 158 * @return Builder 159 */ 160 161 public GeneralCategoryRecommendationPagedQueryResponseBuilder setResults( 162 Function<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder, com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation> builder) { 163 return results(builder.apply( 164 com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendationBuilder.of())); 165 } 166 167 /** 168 * value of count} 169 * @return count 170 */ 171 172 public Long getCount() { 173 return this.count; 174 } 175 176 /** 177 * value of total} 178 * @return total 179 */ 180 181 public Long getTotal() { 182 return this.total; 183 } 184 185 /** 186 * <p>Number of elements skipped.</p> 187 * @return offset 188 */ 189 190 public Long getOffset() { 191 return this.offset; 192 } 193 194 /** 195 * value of results} 196 * @return results 197 */ 198 199 public java.util.List<com.commercetools.ml.models.general_category_recommendations.GeneralCategoryRecommendation> getResults() { 200 return this.results; 201 } 202 203 /** 204 * builds GeneralCategoryRecommendationPagedQueryResponse with checking for non-null required values 205 * @return GeneralCategoryRecommendationPagedQueryResponse 206 */ 207 public GeneralCategoryRecommendationPagedQueryResponse build() { 208 Objects.requireNonNull(count, GeneralCategoryRecommendationPagedQueryResponse.class + ": count is missing"); 209 Objects.requireNonNull(total, GeneralCategoryRecommendationPagedQueryResponse.class + ": total is missing"); 210 Objects.requireNonNull(offset, GeneralCategoryRecommendationPagedQueryResponse.class + ": offset is missing"); 211 Objects.requireNonNull(results, GeneralCategoryRecommendationPagedQueryResponse.class + ": results is missing"); 212 return new GeneralCategoryRecommendationPagedQueryResponseImpl(count, total, offset, results); 213 } 214 215 /** 216 * builds GeneralCategoryRecommendationPagedQueryResponse without checking for non-null required values 217 * @return GeneralCategoryRecommendationPagedQueryResponse 218 */ 219 public GeneralCategoryRecommendationPagedQueryResponse buildUnchecked() { 220 return new GeneralCategoryRecommendationPagedQueryResponseImpl(count, total, offset, results); 221 } 222 223 /** 224 * factory method for an instance of GeneralCategoryRecommendationPagedQueryResponseBuilder 225 * @return builder 226 */ 227 public static GeneralCategoryRecommendationPagedQueryResponseBuilder of() { 228 return new GeneralCategoryRecommendationPagedQueryResponseBuilder(); 229 } 230 231 /** 232 * create builder for GeneralCategoryRecommendationPagedQueryResponse instance 233 * @param template instance with prefilled values for the builder 234 * @return builder 235 */ 236 public static GeneralCategoryRecommendationPagedQueryResponseBuilder of( 237 final GeneralCategoryRecommendationPagedQueryResponse template) { 238 GeneralCategoryRecommendationPagedQueryResponseBuilder builder = new GeneralCategoryRecommendationPagedQueryResponseBuilder(); 239 builder.count = template.getCount(); 240 builder.total = template.getTotal(); 241 builder.offset = template.getOffset(); 242 builder.results = template.getResults(); 243 return builder; 244 } 245 246}