io.sphere.sdk.products.ProductVariantDraftBuilder Maven / Gradle / Ivy
package io.sphere.sdk.products;
import io.sphere.sdk.products.attributes.AttributeDraft;
import io.sphere.sdk.products.attributes.NamedAttributeAccess;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.utils.ListUtils;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
public final class ProductVariantDraftBuilder extends Base implements Builder {
@Nullable
private String sku;
private List prices = Collections.emptyList();
private List attributes = Collections.emptyList();
private List images = Collections.emptyList();
private ProductVariantDraftBuilder() {
}
public static ProductVariantDraftBuilder of() {
return new ProductVariantDraftBuilder();
}
public ProductVariantDraftBuilder sku(@Nullable final String sku) {
this.sku = sku;
return this;
}
public ProductVariantDraftBuilder images(final List images) {
this.images = images;
return this;
}
public ProductVariantDraftBuilder images(final Image image) {
return images(Collections.singletonList(image));
}
public ProductVariantDraftBuilder prices(final List prices) {
this.prices = prices;
return this;
}
public ProductVariantDraftBuilder prices(final Price ... prices) {
return prices(asList(prices));
}
public ProductVariantDraftBuilder price(final Price price) {
return prices(Collections.singletonList(price));
}
public ProductVariantDraftBuilder attributes(final List attributes) {
this.attributes = attributes;
return this;
}
public ProductVariantDraftBuilder attributes(final AttributeDraft ... attributes) {
return attributes(asList(attributes));
}
public ProductVariantDraftBuilder plusAttribute(final NamedAttributeAccess namedAccess, final T value) {
return plusAttribute(AttributeDraft.of(namedAccess, value));
}
public ProductVariantDraftBuilder plusAttribute(final String name, final T value) {
return plusAttribute(AttributeDraft.of(name, value));
}
public ProductVariantDraftBuilder plusAttribute(final AttributeDraft attribute) {
return attributes(ListUtils.listOf(attributes, attribute));
}
@Override
public ProductVariantDraft build() {
return new ProductVariantDraftImpl(sku, prices, attributes, images);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy