001 002package com.commercetools.api.models.cart; 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 * CartSetLineItemCustomTypeActionBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * CartSetLineItemCustomTypeAction cartSetLineItemCustomTypeAction = CartSetLineItemCustomTypeAction.builder() 019 * .lineItemId("{lineItemId}") 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class CartSetLineItemCustomTypeActionBuilder implements Builder<CartSetLineItemCustomTypeAction> { 026 027 private String lineItemId; 028 029 @Nullable 030 private com.commercetools.api.models.type.TypeResourceIdentifier type; 031 032 @Nullable 033 private com.commercetools.api.models.type.FieldContainer fields; 034 035 /** 036 * <p><code>id</code> of the LineItem to update.</p> 037 * @param lineItemId value to be set 038 * @return Builder 039 */ 040 041 public CartSetLineItemCustomTypeActionBuilder lineItemId(final String lineItemId) { 042 this.lineItemId = lineItemId; 043 return this; 044 } 045 046 /** 047 * <p>Defines the Type that extends the Line Item with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Line Item.</p> 048 * @param builder function to build the type value 049 * @return Builder 050 */ 051 052 public CartSetLineItemCustomTypeActionBuilder type( 053 Function<com.commercetools.api.models.type.TypeResourceIdentifierBuilder, com.commercetools.api.models.type.TypeResourceIdentifierBuilder> builder) { 054 this.type = builder.apply(com.commercetools.api.models.type.TypeResourceIdentifierBuilder.of()).build(); 055 return this; 056 } 057 058 /** 059 * <p>Defines the Type that extends the Line Item with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Line Item.</p> 060 * @param builder function to build the type value 061 * @return Builder 062 */ 063 064 public CartSetLineItemCustomTypeActionBuilder withType( 065 Function<com.commercetools.api.models.type.TypeResourceIdentifierBuilder, com.commercetools.api.models.type.TypeResourceIdentifier> builder) { 066 this.type = builder.apply(com.commercetools.api.models.type.TypeResourceIdentifierBuilder.of()); 067 return this; 068 } 069 070 /** 071 * <p>Defines the Type that extends the Line Item with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Line Item.</p> 072 * @param type value to be set 073 * @return Builder 074 */ 075 076 public CartSetLineItemCustomTypeActionBuilder type( 077 @Nullable final com.commercetools.api.models.type.TypeResourceIdentifier type) { 078 this.type = type; 079 return this; 080 } 081 082 /** 083 * <p>Sets the Custom Fields fields for the Line Item.</p> 084 * @param builder function to build the fields value 085 * @return Builder 086 */ 087 088 public CartSetLineItemCustomTypeActionBuilder fields( 089 Function<com.commercetools.api.models.type.FieldContainerBuilder, com.commercetools.api.models.type.FieldContainerBuilder> builder) { 090 this.fields = builder.apply(com.commercetools.api.models.type.FieldContainerBuilder.of()).build(); 091 return this; 092 } 093 094 /** 095 * <p>Sets the Custom Fields fields for the Line Item.</p> 096 * @param builder function to build the fields value 097 * @return Builder 098 */ 099 100 public CartSetLineItemCustomTypeActionBuilder withFields( 101 Function<com.commercetools.api.models.type.FieldContainerBuilder, com.commercetools.api.models.type.FieldContainer> builder) { 102 this.fields = builder.apply(com.commercetools.api.models.type.FieldContainerBuilder.of()); 103 return this; 104 } 105 106 /** 107 * <p>Sets the Custom Fields fields for the Line Item.</p> 108 * @param fields value to be set 109 * @return Builder 110 */ 111 112 public CartSetLineItemCustomTypeActionBuilder fields( 113 @Nullable final com.commercetools.api.models.type.FieldContainer fields) { 114 this.fields = fields; 115 return this; 116 } 117 118 /** 119 * <p><code>id</code> of the LineItem to update.</p> 120 * @return lineItemId 121 */ 122 123 public String getLineItemId() { 124 return this.lineItemId; 125 } 126 127 /** 128 * <p>Defines the Type that extends the Line Item with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Line Item.</p> 129 * @return type 130 */ 131 132 @Nullable 133 public com.commercetools.api.models.type.TypeResourceIdentifier getType() { 134 return this.type; 135 } 136 137 /** 138 * <p>Sets the Custom Fields fields for the Line Item.</p> 139 * @return fields 140 */ 141 142 @Nullable 143 public com.commercetools.api.models.type.FieldContainer getFields() { 144 return this.fields; 145 } 146 147 /** 148 * builds CartSetLineItemCustomTypeAction with checking for non-null required values 149 * @return CartSetLineItemCustomTypeAction 150 */ 151 public CartSetLineItemCustomTypeAction build() { 152 Objects.requireNonNull(lineItemId, CartSetLineItemCustomTypeAction.class + ": lineItemId is missing"); 153 return new CartSetLineItemCustomTypeActionImpl(lineItemId, type, fields); 154 } 155 156 /** 157 * builds CartSetLineItemCustomTypeAction without checking for non-null required values 158 * @return CartSetLineItemCustomTypeAction 159 */ 160 public CartSetLineItemCustomTypeAction buildUnchecked() { 161 return new CartSetLineItemCustomTypeActionImpl(lineItemId, type, fields); 162 } 163 164 /** 165 * factory method for an instance of CartSetLineItemCustomTypeActionBuilder 166 * @return builder 167 */ 168 public static CartSetLineItemCustomTypeActionBuilder of() { 169 return new CartSetLineItemCustomTypeActionBuilder(); 170 } 171 172 /** 173 * create builder for CartSetLineItemCustomTypeAction instance 174 * @param template instance with prefilled values for the builder 175 * @return builder 176 */ 177 public static CartSetLineItemCustomTypeActionBuilder of(final CartSetLineItemCustomTypeAction template) { 178 CartSetLineItemCustomTypeActionBuilder builder = new CartSetLineItemCustomTypeActionBuilder(); 179 builder.lineItemId = template.getLineItemId(); 180 builder.type = template.getType(); 181 builder.fields = template.getFields(); 182 return builder; 183 } 184 185}