io.sphere.sdk.products.ProductVariantDraftBuilder Maven / Gradle / Ivy
package io.sphere.sdk.products;
import java.util.Optional;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.attributes.Attribute;
import io.sphere.sdk.utils.ListUtils;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public final class ProductVariantDraftBuilder extends Base implements Builder {
private Optional sku = Optional.empty();
private List prices = Collections.emptyList();
private List attributes = Collections.emptyList();
private ProductVariantDraftBuilder() {
}
public static ProductVariantDraftBuilder of() {
return new ProductVariantDraftBuilder();
}
public ProductVariantDraftBuilder sku(final Optional sku) {
this.sku = sku;
return this;
}
public ProductVariantDraftBuilder sku(final String sku) {
return sku(Optional.ofNullable(sku));
}
public ProductVariantDraftBuilder prices(final List prices) {
this.prices = prices;
return this;
}
public ProductVariantDraftBuilder prices(final Price ... prices) {
return prices(Arrays.asList(prices));
}
public ProductVariantDraftBuilder price(final Price price) {
return prices(Arrays.asList(price));
}
public ProductVariantDraftBuilder attributes(final List attributes) {
this.attributes = attributes;
return this;
}
public ProductVariantDraftBuilder attributes(final Attribute ... attributes) {
return attributes(Arrays.asList(attributes));
}
public ProductVariantDraftBuilder plusAttribute(final Attribute attribute) {
return attributes(ListUtils.listOf(attributes, attribute));
}
@Override
public ProductVariantDraft build() {
return new ProductVariantDraftImpl(sku, prices, attributes);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy