001 002package com.commercetools.api.models.standalone_price; 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 * StandalonePriceAddPriceTierActionBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * StandalonePriceAddPriceTierAction standalonePriceAddPriceTierAction = StandalonePriceAddPriceTierAction.builder() 017 * .tier(tierBuilder -> tierBuilder) 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 StandalonePriceAddPriceTierActionBuilder implements Builder<StandalonePriceAddPriceTierAction> { 024 025 private com.commercetools.api.models.common.PriceTierDraft tier; 026 027 /** 028 * <p>The PriceTier to be added to the <code>tiers</code> field of the StandalonePrice. The action returns an InvalidField error in the following cases:</p> 029 * <ul> 030 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> < <code>2</code>.</li> 031 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> that already exists for the StandalonePrice.</li> 032 * </ul> 033 * @param builder function to build the tier value 034 * @return Builder 035 */ 036 037 public StandalonePriceAddPriceTierActionBuilder tier( 038 Function<com.commercetools.api.models.common.PriceTierDraftBuilder, com.commercetools.api.models.common.PriceTierDraftBuilder> builder) { 039 this.tier = builder.apply(com.commercetools.api.models.common.PriceTierDraftBuilder.of()).build(); 040 return this; 041 } 042 043 /** 044 * <p>The PriceTier to be added to the <code>tiers</code> field of the StandalonePrice. The action returns an InvalidField error in the following cases:</p> 045 * <ul> 046 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> < <code>2</code>.</li> 047 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> that already exists for the StandalonePrice.</li> 048 * </ul> 049 * @param builder function to build the tier value 050 * @return Builder 051 */ 052 053 public StandalonePriceAddPriceTierActionBuilder withTier( 054 Function<com.commercetools.api.models.common.PriceTierDraftBuilder, com.commercetools.api.models.common.PriceTierDraft> builder) { 055 this.tier = builder.apply(com.commercetools.api.models.common.PriceTierDraftBuilder.of()); 056 return this; 057 } 058 059 /** 060 * <p>The PriceTier to be added to the <code>tiers</code> field of the StandalonePrice. The action returns an InvalidField error in the following cases:</p> 061 * <ul> 062 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> < <code>2</code>.</li> 063 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> that already exists for the StandalonePrice.</li> 064 * </ul> 065 * @param tier value to be set 066 * @return Builder 067 */ 068 069 public StandalonePriceAddPriceTierActionBuilder tier( 070 final com.commercetools.api.models.common.PriceTierDraft tier) { 071 this.tier = tier; 072 return this; 073 } 074 075 /** 076 * <p>The PriceTier to be added to the <code>tiers</code> field of the StandalonePrice. The action returns an InvalidField error in the following cases:</p> 077 * <ul> 078 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> < <code>2</code>.</li> 079 * <li>Trying to add a PriceTier with <code>minimumQuantity</code> that already exists for the StandalonePrice.</li> 080 * </ul> 081 * @return tier 082 */ 083 084 public com.commercetools.api.models.common.PriceTierDraft getTier() { 085 return this.tier; 086 } 087 088 /** 089 * builds StandalonePriceAddPriceTierAction with checking for non-null required values 090 * @return StandalonePriceAddPriceTierAction 091 */ 092 public StandalonePriceAddPriceTierAction build() { 093 Objects.requireNonNull(tier, StandalonePriceAddPriceTierAction.class + ": tier is missing"); 094 return new StandalonePriceAddPriceTierActionImpl(tier); 095 } 096 097 /** 098 * builds StandalonePriceAddPriceTierAction without checking for non-null required values 099 * @return StandalonePriceAddPriceTierAction 100 */ 101 public StandalonePriceAddPriceTierAction buildUnchecked() { 102 return new StandalonePriceAddPriceTierActionImpl(tier); 103 } 104 105 /** 106 * factory method for an instance of StandalonePriceAddPriceTierActionBuilder 107 * @return builder 108 */ 109 public static StandalonePriceAddPriceTierActionBuilder of() { 110 return new StandalonePriceAddPriceTierActionBuilder(); 111 } 112 113 /** 114 * create builder for StandalonePriceAddPriceTierAction instance 115 * @param template instance with prefilled values for the builder 116 * @return builder 117 */ 118 public static StandalonePriceAddPriceTierActionBuilder of(final StandalonePriceAddPriceTierAction template) { 119 StandalonePriceAddPriceTierActionBuilder builder = new StandalonePriceAddPriceTierActionBuilder(); 120 builder.tier = template.getTier(); 121 return builder; 122 } 123 124}