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 * CartSetShippingMethodActionBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * CartSetShippingMethodAction cartSetShippingMethodAction = CartSetShippingMethodAction.builder() 019 * .build() 020 * </code></pre> 021 * </div> 022 */ 023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 024public class CartSetShippingMethodActionBuilder implements Builder<CartSetShippingMethodAction> { 025 026 @Nullable 027 private com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifier shippingMethod; 028 029 @Nullable 030 private com.commercetools.api.models.cart.ExternalTaxRateDraft externalTaxRate; 031 032 /** 033 * <p>Value to set. If empty, any existing value is removed.</p> 034 * <p>If the referenced Shipping Method has a predicate that does not match the Cart, an InvalidOperation error is returned.</p> 035 * @param builder function to build the shippingMethod value 036 * @return Builder 037 */ 038 039 public CartSetShippingMethodActionBuilder shippingMethod( 040 Function<com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifierBuilder, com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifierBuilder> builder) { 041 this.shippingMethod = builder 042 .apply(com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifierBuilder.of()) 043 .build(); 044 return this; 045 } 046 047 /** 048 * <p>Value to set. If empty, any existing value is removed.</p> 049 * <p>If the referenced Shipping Method has a predicate that does not match the Cart, an InvalidOperation error is returned.</p> 050 * @param builder function to build the shippingMethod value 051 * @return Builder 052 */ 053 054 public CartSetShippingMethodActionBuilder withShippingMethod( 055 Function<com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifierBuilder, com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifier> builder) { 056 this.shippingMethod = builder 057 .apply(com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifierBuilder.of()); 058 return this; 059 } 060 061 /** 062 * <p>Value to set. If empty, any existing value is removed.</p> 063 * <p>If the referenced Shipping Method has a predicate that does not match the Cart, an InvalidOperation error is returned.</p> 064 * @param shippingMethod value to be set 065 * @return Builder 066 */ 067 068 public CartSetShippingMethodActionBuilder shippingMethod( 069 @Nullable final com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifier shippingMethod) { 070 this.shippingMethod = shippingMethod; 071 return this; 072 } 073 074 /** 075 * <p>An external Tax Rate can be set if the Cart has the <code>External</code> TaxMode.</p> 076 * @param builder function to build the externalTaxRate value 077 * @return Builder 078 */ 079 080 public CartSetShippingMethodActionBuilder externalTaxRate( 081 Function<com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder, com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder> builder) { 082 this.externalTaxRate = builder.apply(com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder.of()) 083 .build(); 084 return this; 085 } 086 087 /** 088 * <p>An external Tax Rate can be set if the Cart has the <code>External</code> TaxMode.</p> 089 * @param builder function to build the externalTaxRate value 090 * @return Builder 091 */ 092 093 public CartSetShippingMethodActionBuilder withExternalTaxRate( 094 Function<com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder, com.commercetools.api.models.cart.ExternalTaxRateDraft> builder) { 095 this.externalTaxRate = builder.apply(com.commercetools.api.models.cart.ExternalTaxRateDraftBuilder.of()); 096 return this; 097 } 098 099 /** 100 * <p>An external Tax Rate can be set if the Cart has the <code>External</code> TaxMode.</p> 101 * @param externalTaxRate value to be set 102 * @return Builder 103 */ 104 105 public CartSetShippingMethodActionBuilder externalTaxRate( 106 @Nullable final com.commercetools.api.models.cart.ExternalTaxRateDraft externalTaxRate) { 107 this.externalTaxRate = externalTaxRate; 108 return this; 109 } 110 111 /** 112 * <p>Value to set. If empty, any existing value is removed.</p> 113 * <p>If the referenced Shipping Method has a predicate that does not match the Cart, an InvalidOperation error is returned.</p> 114 * @return shippingMethod 115 */ 116 117 @Nullable 118 public com.commercetools.api.models.shipping_method.ShippingMethodResourceIdentifier getShippingMethod() { 119 return this.shippingMethod; 120 } 121 122 /** 123 * <p>An external Tax Rate can be set if the Cart has the <code>External</code> TaxMode.</p> 124 * @return externalTaxRate 125 */ 126 127 @Nullable 128 public com.commercetools.api.models.cart.ExternalTaxRateDraft getExternalTaxRate() { 129 return this.externalTaxRate; 130 } 131 132 /** 133 * builds CartSetShippingMethodAction with checking for non-null required values 134 * @return CartSetShippingMethodAction 135 */ 136 public CartSetShippingMethodAction build() { 137 return new CartSetShippingMethodActionImpl(shippingMethod, externalTaxRate); 138 } 139 140 /** 141 * builds CartSetShippingMethodAction without checking for non-null required values 142 * @return CartSetShippingMethodAction 143 */ 144 public CartSetShippingMethodAction buildUnchecked() { 145 return new CartSetShippingMethodActionImpl(shippingMethod, externalTaxRate); 146 } 147 148 /** 149 * factory method for an instance of CartSetShippingMethodActionBuilder 150 * @return builder 151 */ 152 public static CartSetShippingMethodActionBuilder of() { 153 return new CartSetShippingMethodActionBuilder(); 154 } 155 156 /** 157 * create builder for CartSetShippingMethodAction instance 158 * @param template instance with prefilled values for the builder 159 * @return builder 160 */ 161 public static CartSetShippingMethodActionBuilder of(final CartSetShippingMethodAction template) { 162 CartSetShippingMethodActionBuilder builder = new CartSetShippingMethodActionBuilder(); 163 builder.shippingMethod = template.getShippingMethod(); 164 builder.externalTaxRate = template.getExternalTaxRate(); 165 return builder; 166 } 167 168}