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

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

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

import java.util.Optional;
import io.sphere.sdk.models.DefaultModelFluentBuilder;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.producttypes.ProductType;
import io.sphere.sdk.taxcategories.TaxCategory;

/**
 Builds test doubles1 for products.

 

Example:

{@include.example io.sphere.sdk.products.ProductBuilderTest#demoUsage()} */ public class ProductBuilder extends DefaultModelFluentBuilder { private final Reference productType; private final ProductCatalogData masterData; private Optional> taxCategory = Optional.empty(); private ProductBuilder(final Reference productType, final ProductCatalogData masterData) { this.productType = productType; this.masterData = masterData; } public static ProductBuilder of(final Referenceable productType, final ProductCatalogData masterData) { return new ProductBuilder(productType.toReference(), masterData); } public ProductBuilder taxCategory(final Optional> taxCategory) { this.taxCategory = taxCategory; return getThis(); } public ProductBuilder taxCategory(final Referenceable taxCategory) { return taxCategory(Optional.of(taxCategory.toReference())); } @Override protected ProductBuilder getThis() { return this; } @Override public Product build() { return new ProductImpl(id, version, createdAt, lastModifiedAt, productType, masterData, taxCategory); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy