001 002package com.commercetools.history.models.label; 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 * PaymentLabelBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * PaymentLabel paymentLabel = PaymentLabel.builder() 017 * .key("{key}") 018 * .amountPlanned(amountPlannedBuilder -> amountPlannedBuilder) 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 PaymentLabelBuilder implements Builder<PaymentLabel> { 025 026 private String key; 027 028 private com.commercetools.history.models.common.Money amountPlanned; 029 030 /** 031 * <p>User-defined unique identifier of the Payment.</p> 032 * @param key value to be set 033 * @return Builder 034 */ 035 036 public PaymentLabelBuilder key(final String key) { 037 this.key = key; 038 return this; 039 } 040 041 /** 042 * <p>Money value the Payment intends to receive from the Customer.</p> 043 * @param builder function to build the amountPlanned value 044 * @return Builder 045 */ 046 047 public PaymentLabelBuilder amountPlanned( 048 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.MoneyBuilder> builder) { 049 this.amountPlanned = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()).build(); 050 return this; 051 } 052 053 /** 054 * <p>Money value the Payment intends to receive from the Customer.</p> 055 * @param builder function to build the amountPlanned value 056 * @return Builder 057 */ 058 059 public PaymentLabelBuilder withAmountPlanned( 060 Function<com.commercetools.history.models.common.MoneyBuilder, com.commercetools.history.models.common.Money> builder) { 061 this.amountPlanned = builder.apply(com.commercetools.history.models.common.MoneyBuilder.of()); 062 return this; 063 } 064 065 /** 066 * <p>Money value the Payment intends to receive from the Customer.</p> 067 * @param amountPlanned value to be set 068 * @return Builder 069 */ 070 071 public PaymentLabelBuilder amountPlanned(final com.commercetools.history.models.common.Money amountPlanned) { 072 this.amountPlanned = amountPlanned; 073 return this; 074 } 075 076 /** 077 * <p>User-defined unique identifier of the Payment.</p> 078 * @return key 079 */ 080 081 public String getKey() { 082 return this.key; 083 } 084 085 /** 086 * <p>Money value the Payment intends to receive from the Customer.</p> 087 * @return amountPlanned 088 */ 089 090 public com.commercetools.history.models.common.Money getAmountPlanned() { 091 return this.amountPlanned; 092 } 093 094 /** 095 * builds PaymentLabel with checking for non-null required values 096 * @return PaymentLabel 097 */ 098 public PaymentLabel build() { 099 Objects.requireNonNull(key, PaymentLabel.class + ": key is missing"); 100 Objects.requireNonNull(amountPlanned, PaymentLabel.class + ": amountPlanned is missing"); 101 return new PaymentLabelImpl(key, amountPlanned); 102 } 103 104 /** 105 * builds PaymentLabel without checking for non-null required values 106 * @return PaymentLabel 107 */ 108 public PaymentLabel buildUnchecked() { 109 return new PaymentLabelImpl(key, amountPlanned); 110 } 111 112 /** 113 * factory method for an instance of PaymentLabelBuilder 114 * @return builder 115 */ 116 public static PaymentLabelBuilder of() { 117 return new PaymentLabelBuilder(); 118 } 119 120 /** 121 * create builder for PaymentLabel instance 122 * @param template instance with prefilled values for the builder 123 * @return builder 124 */ 125 public static PaymentLabelBuilder of(final PaymentLabel template) { 126 PaymentLabelBuilder builder = new PaymentLabelBuilder(); 127 builder.key = template.getKey(); 128 builder.amountPlanned = template.getAmountPlanned(); 129 return builder; 130 } 131 132}