io.sphere.sdk.products.ProductProjection Maven / Gradle / Ivy
package io.sphere.sdk.products;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.sphere.sdk.categories.Category;
import io.sphere.sdk.models.LocalizedStrings;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.models.Versioned;
import io.sphere.sdk.search.SearchKeywords;
import java.util.List;
import java.util.Optional;
/**
A projected representation of a product shows the product with its current or staged data.
{@link io.sphere.sdk.products.ProductProjection}s are views of {@link io.sphere.sdk.products.Product}s.
To create, update or delete {@link io.sphere.sdk.products.ProductProjection}s you have to use the
{@link io.sphere.sdk.products.Product} lifecycle classes.
Operations:
- Fetch by ID with {@link io.sphere.sdk.products.queries.ProductProjectionByIdFetch}
If you need {@link io.sphere.sdk.products.ProductProjection} for a method but you have a product,
you can transform a product into a product projection:
{@include.example io.sphere.sdk.products.ProductProjectionTest#transformProductIntoProductProjection()}
{@link ProductProjection#toReference()} returns not are reference to a {@link io.sphere.sdk.products.ProductProjection} but to a {@link io.sphere.sdk.products.Product}.
*/
@JsonDeserialize(as=ProductProjectionImpl.class)
public interface ProductProjection extends ProductLike, ProductDataLike, Referenceable {
public boolean hasStagedChanges();
public boolean isPublished();
@Override
default Reference toReference() {
return Product.reference(getId());
}
public static TypeReference typeReference(){
return new TypeReference() {
@Override
public String toString() {
return "TypeReference";
}
};
}
default Versioned toProductVersioned() {
return Versioned.of(getId(), getVersion());
}
@Override
List> getCategories();
@Override
Optional getDescription();
@Override
ProductVariant getMasterVariant();
@Override
Optional getMetaDescription();
@Override
Optional getMetaKeywords();
@Override
Optional getMetaTitle();
@Override
LocalizedStrings getName();
@Override
LocalizedStrings getSlug();
@Override
List getVariants();
@Override
default List getAllVariants() {
return ProductsPackage.getAllVariants(this);
}
@Override
default Optional getVariant(final int variantId){
return ProductsPackage.getVariant(variantId, this);
}
@Override
default ProductVariant getVariantOrMaster(final int variantId) {
return ProductsPackage.getVariantOrMaster(variantId, this);
}
@Override
SearchKeywords getSearchKeywords();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy