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

io.sphere.sdk.products.NewProductBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.0-M7
Show newest version
package io.sphere.sdk.products;

import io.sphere.sdk.models.*;
import io.sphere.sdk.producttypes.ProductType;

import java.util.Collections;
import java.util.List;

public final class NewProductBuilder extends ProductDataNewProductBuilderBase implements Builder {

    private Reference productType;
    private final NewProductVariant masterVariant;
    private List variants = Collections.emptyList();

    private NewProductBuilder(final Reference productType, LocalizedString name, LocalizedString slug, final NewProductVariant masterVariant) {
        super(name, slug);
        this.productType = productType;
        this.masterVariant = masterVariant;
    }

    public static NewProductBuilder of(final Referenceable productType, LocalizedString name, LocalizedString slug, final NewProductVariant masterVariant) {
        return new NewProductBuilder(productType.toReference(), name, slug, masterVariant);
    }

    @Override
    public NewProduct build() {
        return new NewProductImpl(productType, getName(), getSlug(), getDescription(), getCategories(), MetaAttributes.of(getMetaTitle(), getMetaDescription(), getMetaKeywords()), masterVariant, variants);
    }

    @Override
    protected NewProductBuilder getThis() {
        return this;
    }

    public NewProductBuilder variants(final List variants) {
        this.variants = variants;
        return getThis();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy