001 002package com.commercetools.importapi.models.importrequests; 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 * ProductTypeImportRequestBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * ProductTypeImportRequest productTypeImportRequest = ProductTypeImportRequest.builder() 017 * .plusResources(resourcesBuilder -> resourcesBuilder) 018 * .build() 019 * </code></pre> 020 * </div> 021 */ 022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 023public class ProductTypeImportRequestBuilder implements Builder<ProductTypeImportRequest> { 024 025 private java.util.List<com.commercetools.importapi.models.producttypes.ProductTypeImport> resources; 026 027 /** 028 * <p>The product type import resources of this request.</p> 029 * @param resources value to be set 030 * @return Builder 031 */ 032 033 public ProductTypeImportRequestBuilder resources( 034 final com.commercetools.importapi.models.producttypes.ProductTypeImport... resources) { 035 this.resources = new ArrayList<>(Arrays.asList(resources)); 036 return this; 037 } 038 039 /** 040 * <p>The product type import resources of this request.</p> 041 * @param resources value to be set 042 * @return Builder 043 */ 044 045 public ProductTypeImportRequestBuilder resources( 046 final java.util.List<com.commercetools.importapi.models.producttypes.ProductTypeImport> resources) { 047 this.resources = resources; 048 return this; 049 } 050 051 /** 052 * <p>The product type import resources of this request.</p> 053 * @param resources value to be set 054 * @return Builder 055 */ 056 057 public ProductTypeImportRequestBuilder plusResources( 058 final com.commercetools.importapi.models.producttypes.ProductTypeImport... resources) { 059 if (this.resources == null) { 060 this.resources = new ArrayList<>(); 061 } 062 this.resources.addAll(Arrays.asList(resources)); 063 return this; 064 } 065 066 /** 067 * <p>The product type import resources of this request.</p> 068 * @param builder function to build the resources value 069 * @return Builder 070 */ 071 072 public ProductTypeImportRequestBuilder plusResources( 073 Function<com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder, com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder> builder) { 074 if (this.resources == null) { 075 this.resources = new ArrayList<>(); 076 } 077 this.resources.add( 078 builder.apply(com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder.of()).build()); 079 return this; 080 } 081 082 /** 083 * <p>The product type import resources of this request.</p> 084 * @param builder function to build the resources value 085 * @return Builder 086 */ 087 088 public ProductTypeImportRequestBuilder withResources( 089 Function<com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder, com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder> builder) { 090 this.resources = new ArrayList<>(); 091 this.resources.add( 092 builder.apply(com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder.of()).build()); 093 return this; 094 } 095 096 /** 097 * <p>The product type import resources of this request.</p> 098 * @param builder function to build the resources value 099 * @return Builder 100 */ 101 102 public ProductTypeImportRequestBuilder addResources( 103 Function<com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder, com.commercetools.importapi.models.producttypes.ProductTypeImport> builder) { 104 return plusResources( 105 builder.apply(com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder.of())); 106 } 107 108 /** 109 * <p>The product type import resources of this request.</p> 110 * @param builder function to build the resources value 111 * @return Builder 112 */ 113 114 public ProductTypeImportRequestBuilder setResources( 115 Function<com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder, com.commercetools.importapi.models.producttypes.ProductTypeImport> builder) { 116 return resources(builder.apply(com.commercetools.importapi.models.producttypes.ProductTypeImportBuilder.of())); 117 } 118 119 /** 120 * <p>The product type import resources of this request.</p> 121 * @return resources 122 */ 123 124 public java.util.List<com.commercetools.importapi.models.producttypes.ProductTypeImport> getResources() { 125 return this.resources; 126 } 127 128 /** 129 * builds ProductTypeImportRequest with checking for non-null required values 130 * @return ProductTypeImportRequest 131 */ 132 public ProductTypeImportRequest build() { 133 Objects.requireNonNull(resources, ProductTypeImportRequest.class + ": resources is missing"); 134 return new ProductTypeImportRequestImpl(resources); 135 } 136 137 /** 138 * builds ProductTypeImportRequest without checking for non-null required values 139 * @return ProductTypeImportRequest 140 */ 141 public ProductTypeImportRequest buildUnchecked() { 142 return new ProductTypeImportRequestImpl(resources); 143 } 144 145 /** 146 * factory method for an instance of ProductTypeImportRequestBuilder 147 * @return builder 148 */ 149 public static ProductTypeImportRequestBuilder of() { 150 return new ProductTypeImportRequestBuilder(); 151 } 152 153 /** 154 * create builder for ProductTypeImportRequest instance 155 * @param template instance with prefilled values for the builder 156 * @return builder 157 */ 158 public static ProductTypeImportRequestBuilder of(final ProductTypeImportRequest template) { 159 ProductTypeImportRequestBuilder builder = new ProductTypeImportRequestBuilder(); 160 builder.resources = template.getResources(); 161 return builder; 162 } 163 164}