All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.orders.ProductVariantImportDraftBuilder Maven / Gradle / Ivy

The newest version!
package io.sphere.sdk.orders;

import io.sphere.sdk.attributes.Attribute;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.models.Image;
import io.sphere.sdk.products.Price;

import java.util.List;
import java.util.Optional;

public class ProductVariantImportDraftBuilder extends Base implements Builder {
    private final Optional id;
    private final Optional sku;
    private final Optional productId;
    private Optional> prices = Optional.empty();
    private Optional> attributes = Optional.empty();
    private Optional> images = Optional.empty();

    private ProductVariantImportDraftBuilder(final Optional sku, final Optional productId, final Optional id) {
        this.sku = sku;
        this.productId = productId;
        this.id = id;
    }

    public ProductVariantImportDraftBuilder prices(final Optional> prices) {
        this.prices = prices;
        return this;
    }

    /**
     * The prices of the variant. The prices should not contain two prices for the same price scope (same currency, country and customer group). If this property is defined, then it will override the prices property from the original product variant, otherwise prices property from the original product variant would be copied in the resulting order.
     * @param prices the prices to set
     * @return this builder
     */
    public ProductVariantImportDraftBuilder prices(final List prices) {
        return prices(Optional.of(prices));
    }

    public ProductVariantImportDraftBuilder attributes(final Optional> attributes) {
        this.attributes = attributes;
        return this;
    }

    public ProductVariantImportDraftBuilder attributes(final List attributes) {
        return attributes(Optional.of(attributes));
    }

    public ProductVariantImportDraftBuilder images(final Optional> images) {
        this.images = images;
        return this;
    }

    public ProductVariantImportDraftBuilder images(final List images) {
        return images(Optional.of(images));
    }

    public static ProductVariantImportDraftBuilder ofSku(final String sku) {
        return new ProductVariantImportDraftBuilder(Optional.of(sku), Optional.empty(), Optional.empty());
    }

    public static ProductVariantImportDraftBuilder of(final String productId, final int variantId, final String sku) {
        return new ProductVariantImportDraftBuilder(Optional.of(sku), Optional.of(productId), Optional.of(variantId));
    }

    public static ProductVariantImportDraftBuilder of(final String productId, final int variantId) {
        return new ProductVariantImportDraftBuilder(Optional.empty(), Optional.of(productId), Optional.of(variantId));
    }

    @Override
    public ProductVariantImportDraft build() {
        return new ProductVariantImportDraftImpl(id, sku, prices, images, attributes, productId);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy