io.sphere.sdk.orderedits.OrderEditDraftBuilder Maven / Gradle / Ivy
package io.sphere.sdk.orderedits;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.sphere.sdk.commands.StagedUpdateAction;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.orders.Order;
import io.sphere.sdk.types.CustomFieldsDraft;
import io.sphere.sdk.utils.SphereInternalUtils;
import java.lang.Boolean;
import java.lang.String;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import javax.annotation.Nullable;
/**
* Builder for {@link OrderEditDraft}.
*/
@Generated(
value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
comments = "Generated from: io.sphere.sdk.orderedits.OrderEditDraft"
)
public final class OrderEditDraftBuilder extends Base implements Builder {
@Nullable
private String comment;
@Nullable
private CustomFieldsDraft custom;
@Nullable
private Boolean dryRun;
@Nullable
private String key;
private Reference resource;
private List> stagedActions;
OrderEditDraftBuilder() {
}
OrderEditDraftBuilder(@Nullable final String comment, @Nullable final CustomFieldsDraft custom,
@Nullable final Boolean dryRun, @Nullable final String key, final Reference resource,
final List> stagedActions) {
this.comment = comment;
this.custom = custom;
this.dryRun = dryRun;
this.key = key;
this.resource = resource;
this.stagedActions = stagedActions;
}
/**
* Sets the {@code comment} property of this builder.
*
* @param comment the value for {@link OrderEditDraft#getComment()}
* @return this builder
*/
public OrderEditDraftBuilder comment(@Nullable final String comment) {
this.comment = comment;
return this;
}
/**
* Sets the {@code custom} property of this builder.
*
* @param custom the value for {@link OrderEditDraft#getCustom()}
* @return this builder
*/
public OrderEditDraftBuilder custom(@Nullable final CustomFieldsDraft custom) {
this.custom = custom;
return this;
}
/**
* Sets the {@code dryRun} property of this builder.
*
* @param dryRun the value for {@link OrderEditDraft#isDryRun()}
* @return this builder
*/
public OrderEditDraftBuilder dryRun(@Nullable final Boolean dryRun) {
this.dryRun = dryRun;
return this;
}
/**
* Sets the {@code dryRun} property of this builder.
*
* @param dryRun the value for {@link OrderEditDraft#isDryRun()}
* @return this builder
*/
public OrderEditDraftBuilder isDryRun(@Nullable final Boolean dryRun) {
this.dryRun = dryRun;
return this;
}
/**
* Sets the {@code key} property of this builder.
*
* @param key the value for {@link OrderEditDraft#getKey()}
* @return this builder
*/
public OrderEditDraftBuilder key(@Nullable final String key) {
this.key = key;
return this;
}
/**
* Sets the {@code resource} property of this builder.
*
* @param resource the value for {@link OrderEditDraft#getResource()}
* @return this builder
*/
public OrderEditDraftBuilder resource(final Referenceable resource) {
this.resource = Optional.ofNullable(resource).map(Referenceable::toReference).orElse(null);;
return this;
}
/**
* Sets the {@code stagedActions} property of this builder.
*
* @param stagedActions the value for {@link OrderEditDraft#getStagedActions()}
* @return this builder
*/
public OrderEditDraftBuilder stagedActions(
final List> stagedActions) {
this.stagedActions = stagedActions;
return this;
}
@Nullable
public String getComment() {
return comment;
}
@Nullable
public CustomFieldsDraft getCustom() {
return custom;
}
@Nullable
@JsonProperty("dryRun")
public Boolean isDryRun() {
return dryRun;
}
@Nullable
public String getKey() {
return key;
}
public Reference getResource() {
return resource;
}
public List> getStagedActions() {
return stagedActions;
}
/**
* Concatenate {@code stagedActions} parameter to the {@code stagedActions} list property of this builder.
*
* @param stagedActions the value for {@link OrderEditDraft#getStagedActions()}
* @return this builder
*/
public OrderEditDraftBuilder plusStagedActions(
final List> stagedActions) {
this.stagedActions = SphereInternalUtils.listOf(Optional.ofNullable(this.stagedActions).orElseGet(ArrayList::new), stagedActions);
return this;
}
/**
* Adds {@code stagedActions} parameter to the {@code stagedActions} list property of this builder.
*
* @param stagedActions the value of the element to add to {@link OrderEditDraft#getStagedActions()}
* @return this builder
*/
public OrderEditDraftBuilder plusStagedActions(
final StagedUpdateAction stagedActions) {
this.stagedActions = SphereInternalUtils.listOf(Optional.ofNullable(this.stagedActions).orElseGet(ArrayList::new), Collections.singletonList(stagedActions));
return this;
}
/**
* Creates a new instance of {@code OrderEditDraftDsl} with the values of this builder.
*
* @return the instance
*/
public OrderEditDraftDsl build() {
return new OrderEditDraftDsl(comment, custom, dryRun, key, resource, stagedActions);
}
/**
* Creates a new object initialized with the given values.
*
* @param key initial value for the {@link OrderEditDraft#getKey()} property
* @param resource initial value for the {@link OrderEditDraft#getResource()} property
* @param stagedActions initial value for the {@link OrderEditDraft#getStagedActions()} property
* @param custom initial value for the {@link OrderEditDraft#getCustom()} property
* @param comment initial value for the {@link OrderEditDraft#getComment()} property
* @param dryRun initial value for the {@link OrderEditDraft#isDryRun()} property
* @return new object initialized with the given values
*/
public static OrderEditDraftBuilder of(@Nullable final String key,
final Reference resource, final List> stagedActions,
@Nullable final CustomFieldsDraft custom, @Nullable final String comment,
@Nullable final Boolean dryRun) {
return new OrderEditDraftBuilder(comment, custom, dryRun, key, resource, stagedActions);
}
/**
* Creates a new object initialized with the given values.
*
* @param resource initial value for the {@link OrderEditDraft#getResource()} property
* @param stagedActions initial value for the {@link OrderEditDraft#getStagedActions()} property
* @return new object initialized with the given values
*/
public static OrderEditDraftBuilder of(final Reference resource,
final List> stagedActions) {
return new OrderEditDraftBuilder(null, null, null, null, resource, stagedActions);
}
/**
* 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 OrderEditDraftBuilder of(final OrderEditDraft template) {
return new OrderEditDraftBuilder(template.getComment(), template.getCustom(), template.isDryRun(), template.getKey(), template.getResource(), template.getStagedActions());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy