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

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

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

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.Optional;
import io.sphere.sdk.models.Resource;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.states.State;

import javax.annotation.Nullable;

/**

 

A sellable good.

id=operationsOperations:

  • Create a product in SPHERE.IO with {@link io.sphere.sdk.products.commands.ProductCreateCommand}.
  • Query a product with {@link io.sphere.sdk.products.queries.ProductQuery}.
  • Update a product with {@link io.sphere.sdk.products.commands.ProductUpdateCommand}.
  • Delete a product with {@link io.sphere.sdk.products.commands.ProductDeleteCommand}.

Consider to use {@link io.sphere.sdk.products.ProductProjection} for queries if you don't need the whole product data so you can safe traffic and memory.

@see io.sphere.sdk.products.ProductProjection @see io.sphere.sdk.categories.Category @see io.sphere.sdk.producttypes.ProductType @see io.sphere.sdk.productdiscounts.ProductDiscount */ @JsonDeserialize(as=ProductImpl.class) public interface Product extends ProductLike, Resource { ProductCatalogData getMasterData(); /** * Returns this state of this Product. * * @return state of this product or null * * @see io.sphere.sdk.products.commands.updateactions.TransitionState */ @Nullable Reference getState(); static TypeReference typeReference(){ return new TypeReference() { @Override public String toString() { return "TypeReference"; } }; } @Override default Reference toReference() { return reference(this); } static String referenceTypeId(){ return "product"; } /** * * @deprecated use {@link #referenceTypeId()} instead * @return referenceTypeId */ @Deprecated static String typeId(){ return "product"; } static Reference reference(final Product product) { return Reference.of(referenceTypeId(), product.getId(), product); } static Reference reference(final String id) { return Reference.of(referenceTypeId(), id); } @Nullable default ProductProjection toProjection(final ProductProjectionType productProjectionType) { return Optional.ofNullable(getMasterData().get(productProjectionType)) .map(productData -> new ProductToProductProjectionWrapper(this, productProjectionType)) .orElse(null); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy