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

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

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

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.sphere.sdk.categories.Category;
import io.sphere.sdk.models.LocalizedString;
import io.sphere.sdk.models.ResourceViewImpl;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.producttypes.ProductType;
import io.sphere.sdk.search.SearchKeywords;
import io.sphere.sdk.taxcategories.TaxCategory;

import javax.annotation.Nullable;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Set;


class ProductProjectionImpl extends ResourceViewImpl implements ProductProjection {
    private final Reference productType;
    @Nullable
    private final Reference taxCategory;
    @JsonProperty("published")
    private final Boolean isPublished;
    @JsonProperty("hasStagedChanges")
    private final Boolean hasStagedChanges;
    private final LocalizedString name;
    private final Set> categories;
    @Nullable
    private final LocalizedString description;
    private final LocalizedString slug;
    @Nullable
    private final LocalizedString metaTitle;
    @Nullable
    private final LocalizedString metaDescription;
    @Nullable
    private final LocalizedString metaKeywords;
    private final ProductVariant masterVariant;
    private final List variants;
    private final SearchKeywords searchKeywords;
    @Nullable
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private final CategoryOrderHints categoryOrderHints;

    @JsonCreator
    ProductProjectionImpl(final String id, final Long version, final ZonedDateTime createdAt, final ZonedDateTime lastModifiedAt,
                          final Reference productType, @Nullable final Reference taxCategory,
                          final Boolean hasStagedChanges, final LocalizedString name,
                          final Set> categories, final LocalizedString description,
                          final LocalizedString slug, final LocalizedString metaTitle,
                          final LocalizedString metaDescription, final LocalizedString metaKeywords,
                          final ProductVariant masterVariant, final List variants,
                          final Boolean isPublished, final SearchKeywords searchKeywords,
                          @JsonInclude(JsonInclude.Include.NON_EMPTY) final CategoryOrderHints categoryOrderHints) {
        super(id, version, createdAt, lastModifiedAt);
        this.productType = productType;
        this.taxCategory = taxCategory;
        this.hasStagedChanges = hasStagedChanges;
        this.name = name;
        this.categories = categories;
        this.description = description;
        this.slug = slug;
        this.metaTitle = metaTitle;
        this.metaDescription = metaDescription;
        this.metaKeywords = metaKeywords;
        this.masterVariant = masterVariant;
        this.variants = variants;
        this.isPublished = isPublished;
        this.searchKeywords = searchKeywords;
        this.categoryOrderHints = categoryOrderHints;
        getAllVariants().stream()
                .filter(v -> v instanceof ProductVariantImpl)
                .forEach(variant -> ((ProductVariantImpl)variant).setProductId(getId()));
    }

    public Boolean hasStagedChanges() {
        return hasStagedChanges;
    }

    @Override
    public LocalizedString getName() {
        return name;
    }

    @Override
    public Set> getCategories() {
        return categories;
    }

    @Override
    @Nullable
    public LocalizedString getDescription() {
        return description;
    }

    @Override
    public LocalizedString getSlug() {
        return slug;
    }

    @Override
    @Nullable
    public LocalizedString getMetaTitle() {
        return metaTitle;
    }

    @Override
    @Nullable
    public LocalizedString getMetaDescription() {
        return metaDescription;
    }

    @Override
    @Nullable
    public LocalizedString getMetaKeywords() {
        return metaKeywords;
    }

    @Override
    public ProductVariant getMasterVariant() {
        return masterVariant;
    }

    @Override
    public List getVariants() {
        return variants;
    }

    @Override
    public Reference getProductType() {
        return productType;
    }

    @Override
    @Nullable
    public Reference getTaxCategory() {
        return taxCategory;
    }

    @Override
    public Boolean isPublished() {
        return isPublished;
    }

    @Override
    public SearchKeywords getSearchKeywords() {
        return searchKeywords;
    }

    @Override
    @Nullable
    public CategoryOrderHints getCategoryOrderHints() {
        return categoryOrderHints;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy