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