io.sphere.sdk.carts.commands.CartReplicationDraftBuilder Maven / Gradle / Ivy
The newest version!
package io.sphere.sdk.carts.commands;
import io.sphere.sdk.carts.CartLike;
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 java.lang.String;
import java.util.Optional;
import javax.annotation.Generated;
import javax.annotation.Nullable;
/**
* Builder for {@link CartReplicationDraft}.
*/
@Generated(
value = "io.sphere.sdk.annotations.processors.generators.DraftBuilderGenerator",
comments = "Generated from: io.sphere.sdk.carts.commands.CartReplicationDraft"
)
public final class CartReplicationDraftBuilder extends Base implements Builder {
@Nullable
private String key;
private Reference extends CartLike> reference;
CartReplicationDraftBuilder() {
}
CartReplicationDraftBuilder(@Nullable final String key,
final Reference extends CartLike> reference) {
this.key = key;
this.reference = reference;
}
/**
* Sets the {@code key} property of this builder.
*
* @param key the value for {@link CartReplicationDraft#getKey()}
* @return this builder
*/
public CartReplicationDraftBuilder key(@Nullable final String key) {
this.key = key;
return this;
}
/**
* Sets the {@code reference} property of this builder.
*
* @param reference the value for {@link CartReplicationDraft#getReference()}
* @return this builder
*/
public CartReplicationDraftBuilder reference(final Referenceable extends CartLike> reference) {
this.reference = Optional.ofNullable(reference).map(Referenceable::toReference).orElse(null);;
return this;
}
@Nullable
public String getKey() {
return key;
}
public Reference extends CartLike> getReference() {
return reference;
}
/**
* Creates a new instance of {@code CartReplicationDraftDsl} with the values of this builder.
*
* @return the instance
*/
public CartReplicationDraftDsl build() {
return new CartReplicationDraftDsl(key, reference);
}
/**
* Creates a new object initialized with the given values.
*
* @param reference initial value for the {@link CartReplicationDraft#getReference()} property
* @return new object initialized with the given values
*/
public static CartReplicationDraftBuilder of(final Reference extends CartLike> reference) {
return new CartReplicationDraftBuilder(null, reference);
}
/**
* 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 CartReplicationDraftBuilder of(final CartReplicationDraft template) {
return new CartReplicationDraftBuilder(template.getKey(), template.getReference());
}
}