io.sphere.sdk.products.NewProductBuilder Maven / Gradle / Ivy
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();
}
}