001
002package com.commercetools.api.models.payment;
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 * PaymentReferenceBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     PaymentReference paymentReference = PaymentReference.builder()
019 *             .id("{id}")
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 PaymentReferenceBuilder implements Builder<PaymentReference> {
026
027    private String id;
028
029    @Nullable
030    private com.commercetools.api.models.payment.Payment obj;
031
032    /**
033     *  <p>Unique identifier of the referenced Payment.</p>
034     * @param id value to be set
035     * @return Builder
036     */
037
038    public PaymentReferenceBuilder id(final String id) {
039        this.id = id;
040        return this;
041    }
042
043    /**
044     *  <p>Contains the representation of the expanded Payment. Only present in responses to requests with Reference Expansion for Payments.</p>
045     * @param builder function to build the obj value
046     * @return Builder
047     */
048
049    public PaymentReferenceBuilder obj(
050            Function<com.commercetools.api.models.payment.PaymentBuilder, com.commercetools.api.models.payment.PaymentBuilder> builder) {
051        this.obj = builder.apply(com.commercetools.api.models.payment.PaymentBuilder.of()).build();
052        return this;
053    }
054
055    /**
056     *  <p>Contains the representation of the expanded Payment. Only present in responses to requests with Reference Expansion for Payments.</p>
057     * @param builder function to build the obj value
058     * @return Builder
059     */
060
061    public PaymentReferenceBuilder withObj(
062            Function<com.commercetools.api.models.payment.PaymentBuilder, com.commercetools.api.models.payment.Payment> builder) {
063        this.obj = builder.apply(com.commercetools.api.models.payment.PaymentBuilder.of());
064        return this;
065    }
066
067    /**
068     *  <p>Contains the representation of the expanded Payment. Only present in responses to requests with Reference Expansion for Payments.</p>
069     * @param obj value to be set
070     * @return Builder
071     */
072
073    public PaymentReferenceBuilder obj(@Nullable final com.commercetools.api.models.payment.Payment obj) {
074        this.obj = obj;
075        return this;
076    }
077
078    /**
079     *  <p>Unique identifier of the referenced Payment.</p>
080     * @return id
081     */
082
083    public String getId() {
084        return this.id;
085    }
086
087    /**
088     *  <p>Contains the representation of the expanded Payment. Only present in responses to requests with Reference Expansion for Payments.</p>
089     * @return obj
090     */
091
092    @Nullable
093    public com.commercetools.api.models.payment.Payment getObj() {
094        return this.obj;
095    }
096
097    /**
098     * builds PaymentReference with checking for non-null required values
099     * @return PaymentReference
100     */
101    public PaymentReference build() {
102        Objects.requireNonNull(id, PaymentReference.class + ": id is missing");
103        return new PaymentReferenceImpl(id, obj);
104    }
105
106    /**
107     * builds PaymentReference without checking for non-null required values
108     * @return PaymentReference
109     */
110    public PaymentReference buildUnchecked() {
111        return new PaymentReferenceImpl(id, obj);
112    }
113
114    /**
115     * factory method for an instance of PaymentReferenceBuilder
116     * @return builder
117     */
118    public static PaymentReferenceBuilder of() {
119        return new PaymentReferenceBuilder();
120    }
121
122    /**
123     * create builder for PaymentReference instance
124     * @param template instance with prefilled values for the builder
125     * @return builder
126     */
127    public static PaymentReferenceBuilder of(final PaymentReference template) {
128        PaymentReferenceBuilder builder = new PaymentReferenceBuilder();
129        builder.id = template.getId();
130        builder.obj = template.getObj();
131        return builder;
132    }
133
134}