io.sphere.sdk.discountcodes.DiscountCodeDraftBuilderBase Maven / Gradle / Ivy
package io.sphere.sdk.discountcodes;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.sphere.sdk.cartdiscounts.CartDiscount;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.LocalizedString;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.types.CustomFieldsDraft;
import io.sphere.sdk.utils.SphereInternalUtils;
import java.lang.Boolean;
import java.lang.Long;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import javax.annotation.Nullable;
/**
* Abstract base builder for {@link DiscountCodeDraft} which needs to be extended to add additional methods.
* Subclasses have to provide the same non-default constructor as this class.
*/
@Generated(
value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
comments = "Generated from: io.sphere.sdk.discountcodes.DiscountCodeDraft"
)
abstract class DiscountCodeDraftBuilderBase extends Base implements Builder {
Boolean active;
List> cartDiscounts;
@Nullable
String cartPredicate;
String code;
@Nullable
CustomFieldsDraft custom;
@Nullable
LocalizedString description;
@Nullable
List groups;
@Nullable
Long maxApplications;
@Nullable
Long maxApplicationsPerCustomer;
@Nullable
LocalizedString name;
@Nullable
ZonedDateTime validFrom;
@Nullable
ZonedDateTime validUntil;
protected DiscountCodeDraftBuilderBase() {
}
protected DiscountCodeDraftBuilderBase(final Boolean active,
final List> cartDiscounts, @Nullable final String cartPredicate,
final String code, @Nullable final CustomFieldsDraft custom,
@Nullable final LocalizedString description, @Nullable final List groups,
@Nullable final Long maxApplications, @Nullable final Long maxApplicationsPerCustomer,
@Nullable final LocalizedString name, @Nullable final ZonedDateTime validFrom,
@Nullable final ZonedDateTime validUntil) {
this.active = active;
this.cartDiscounts = cartDiscounts;
this.cartPredicate = cartPredicate;
this.code = code;
this.custom = custom;
this.description = description;
this.groups = groups;
this.maxApplications = maxApplications;
this.maxApplicationsPerCustomer = maxApplicationsPerCustomer;
this.name = name;
this.validFrom = validFrom;
this.validUntil = validUntil;
}
/**
* Sets the {@code active} property of this builder.
*
* @param active the value for {@link DiscountCodeDraft#isActive()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T active(final Boolean active) {
this.active = active;
return (T) this;
}
/**
* Sets the {@code active} property of this builder.
*
* @param active the value for {@link DiscountCodeDraft#isActive()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T isActive(final Boolean active) {
this.active = active;
return (T) this;
}
/**
* Sets the {@code cartDiscounts} property of this builder.
*
* @param cartDiscounts the value for {@link DiscountCodeDraft#getCartDiscounts()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T cartDiscounts(final List> cartDiscounts) {
this.cartDiscounts = cartDiscounts;
return (T) this;
}
/**
* Sets the {@code cartPredicate} property of this builder.
*
* @param cartPredicate the value for {@link DiscountCodeDraft#getCartPredicate()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T cartPredicate(@Nullable final String cartPredicate) {
this.cartPredicate = cartPredicate;
return (T) this;
}
/**
* Sets the {@code code} property of this builder.
*
* @param code the value for {@link DiscountCodeDraft#getCode()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T code(final String code) {
this.code = code;
return (T) this;
}
/**
* Sets the {@code custom} property of this builder.
*
* @param custom the value for {@link DiscountCodeDraft#getCustom()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T custom(@Nullable final CustomFieldsDraft custom) {
this.custom = custom;
return (T) this;
}
/**
* Sets the {@code description} property of this builder.
*
* @param description the value for {@link DiscountCodeDraft#getDescription()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T description(@Nullable final LocalizedString description) {
this.description = description;
return (T) this;
}
/**
* Sets the {@code groups} property of this builder.
*
* @param groups the value for {@link DiscountCodeDraft#getGroups()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T groups(@Nullable final List groups) {
this.groups = groups;
return (T) this;
}
/**
* Sets the {@code maxApplications} property of this builder.
*
* @param maxApplications the value for {@link DiscountCodeDraft#getMaxApplications()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T maxApplications(@Nullable final Long maxApplications) {
this.maxApplications = maxApplications;
return (T) this;
}
/**
* Sets the {@code maxApplicationsPerCustomer} property of this builder.
*
* @param maxApplicationsPerCustomer the value for {@link DiscountCodeDraft#getMaxApplicationsPerCustomer()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T maxApplicationsPerCustomer(@Nullable final Long maxApplicationsPerCustomer) {
this.maxApplicationsPerCustomer = maxApplicationsPerCustomer;
return (T) this;
}
/**
* Sets the {@code name} property of this builder.
*
* @param name the value for {@link DiscountCodeDraft#getName()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T name(@Nullable final LocalizedString name) {
this.name = name;
return (T) this;
}
/**
* Sets the {@code validFrom} property of this builder.
*
* @param validFrom the value for {@link DiscountCodeDraft#getValidFrom()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T validFrom(@Nullable final ZonedDateTime validFrom) {
this.validFrom = validFrom;
return (T) this;
}
/**
* Sets the {@code validUntil} property of this builder.
*
* @param validUntil the value for {@link DiscountCodeDraft#getValidUntil()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T validUntil(@Nullable final ZonedDateTime validUntil) {
this.validUntil = validUntil;
return (T) this;
}
@JsonProperty("isActive")
public Boolean isActive() {
return active;
}
public List> getCartDiscounts() {
return cartDiscounts;
}
@Nullable
public String getCartPredicate() {
return cartPredicate;
}
public String getCode() {
return code;
}
@Nullable
public CustomFieldsDraft getCustom() {
return custom;
}
@Nullable
public LocalizedString getDescription() {
return description;
}
@Nullable
public List getGroups() {
return groups;
}
@Nullable
public Long getMaxApplications() {
return maxApplications;
}
@Nullable
public Long getMaxApplicationsPerCustomer() {
return maxApplicationsPerCustomer;
}
@Nullable
public LocalizedString getName() {
return name;
}
@Nullable
public ZonedDateTime getValidFrom() {
return validFrom;
}
@Nullable
public ZonedDateTime getValidUntil() {
return validUntil;
}
/**
* Concatenate {@code cartDiscounts} parameter to the {@code cartDiscounts} list property of this builder.
*
* @param cartDiscounts the value for {@link DiscountCodeDraft#getCartDiscounts()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T plusCartDiscounts(final List> cartDiscounts) {
this.cartDiscounts = SphereInternalUtils.listOf(Optional.ofNullable(this.cartDiscounts).orElseGet(ArrayList::new), cartDiscounts);
return (T) this;
}
/**
* Concatenate {@code groups} parameter to the {@code groups} list property of this builder.
*
* @param groups the value for {@link DiscountCodeDraft#getGroups()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T plusGroups(final List groups) {
this.groups = SphereInternalUtils.listOf(Optional.ofNullable(this.groups).orElseGet(ArrayList::new), groups);
return (T) this;
}
/**
* Adds {@code cartDiscounts} parameter to the {@code cartDiscounts} list property of this builder.
*
* @param cartDiscounts the value of the element to add to {@link DiscountCodeDraft#getCartDiscounts()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T plusCartDiscounts(final Reference cartDiscounts) {
this.cartDiscounts = SphereInternalUtils.listOf(Optional.ofNullable(this.cartDiscounts).orElseGet(ArrayList::new), Collections.singletonList(cartDiscounts));
return (T) this;
}
/**
* Adds {@code groups} parameter to the {@code groups} list property of this builder.
*
* @param groups the value of the element to add to {@link DiscountCodeDraft#getGroups()}
* @return this builder
*/
@SuppressWarnings("unchecked")
public T plusGroups(final String groups) {
this.groups = SphereInternalUtils.listOf(Optional.ofNullable(this.groups).orElseGet(ArrayList::new), Collections.singletonList(groups));
return (T) this;
}
/**
* Creates a new instance of {@code DiscountCodeDraftDsl} with the values of this builder.
*
* @return the instance
*/
public DiscountCodeDraftDsl build() {
return new DiscountCodeDraftDsl(active, cartDiscounts, cartPredicate, code, custom, description, groups, maxApplications, maxApplicationsPerCustomer, name, validFrom, validUntil);
}
/**
* Creates a new object initialized with the given values.
*
* @param code initial value for the {@link DiscountCodeDraft#getCode()} property
* @param cartDiscounts initial value for the {@link DiscountCodeDraft#getCartDiscounts()} property
* @return new object initialized with the given values
*/
public static DiscountCodeDraftBuilder of(final String code,
final List> cartDiscounts) {
return new DiscountCodeDraftBuilder(null, cartDiscounts, null, code, null, null, null, null, null, null, null, null);
}
/**
* Creates a new object initialized with the fields of the template parameter.
*
* @param template the template
* @return a new object initialized from the template
*/
public static DiscountCodeDraftBuilder of(final DiscountCodeDraft template) {
return new DiscountCodeDraftBuilder(template.isActive(), template.getCartDiscounts(), template.getCartPredicate(), template.getCode(), template.getCustom(), template.getDescription(), template.getGroups(), template.getMaxApplications(), template.getMaxApplicationsPerCustomer(), template.getName(), template.getValidFrom(), template.getValidUntil());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy