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

io.sphere.sdk.carts.CartDraftBuilder Maven / Gradle / Ivy

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

import com.neovisionaries.i18n.CountryCode;
import io.sphere.sdk.models.Base;
import io.sphere.sdk.models.Builder;
import io.sphere.sdk.types.CustomFieldsDraft;

import javax.annotation.Nullable;
import javax.money.CurrencyUnit;

/**
 * 

Builder to create {@link CartDraft}s.

* *

Example of creating a cart with custom fields:

* {@include.example io.sphere.sdk.carts.CartsCustomFieldsTest#createCartWithCustomType()} */ public class CartDraftBuilder extends Base implements Builder { private final CurrencyUnit currency; @Nullable private String customerId; @Nullable private CountryCode country; @Nullable private InventoryMode inventoryMode; @Nullable private CustomFieldsDraft custom; CartDraftBuilder(final CurrencyUnit currency, @Nullable final String customerId, @Nullable final CountryCode country, @Nullable final InventoryMode inventoryMode, @Nullable final CustomFieldsDraft custom) { this.currency = currency; this.customerId = customerId; this.country = country; this.inventoryMode = inventoryMode; this.custom = custom; } CartDraftBuilder(final CartDraft template) { this(template.getCurrency(), template.getCustomerId(), template.getCountry(), template.getInventoryMode(), template.getCustom()); } public static CartDraftBuilder of(final CurrencyUnit currency) { return new CartDraftBuilder(CartDraft.of(currency)); } public CartDraftBuilder customerId(@Nullable final String customerId) { this.customerId = customerId; return this; } public CartDraftBuilder country(@Nullable final CountryCode country) { this.country = country; return this; } public CartDraftBuilder inventoryMode(@Nullable final InventoryMode inventoryMode) { this.inventoryMode = inventoryMode; return this; } @Override public CartDraft build() { return new CartDraft(currency, customerId, country, inventoryMode, custom); } public CartDraftBuilder custom(final CustomFieldsDraft custom) { this.custom = custom; return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy