001
002package com.commercetools.api.models.error;
003
004import java.time.*;
005import java.util.*;
006
007import com.fasterxml.jackson.annotation.JsonCreator;
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.*;
010
011import io.vrap.rmf.base.client.ModelBase;
012import io.vrap.rmf.base.client.utils.Generated;
013
014import org.apache.commons.lang3.builder.EqualsBuilder;
015import org.apache.commons.lang3.builder.HashCodeBuilder;
016
017/**
018 *  <p>Returned when a Product is already assigned to a Product Selection, but the Product Selection has either a different Product Variant Selection or a different Product Variant Exclusion.</p>
019 *  <p>The error is returned as a failed response either to the Add Product or to the Exclude Product update action.</p>
020 */
021@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
022public class GraphQLProductPresentWithDifferentVariantSelectionErrorImpl
023        implements GraphQLProductPresentWithDifferentVariantSelectionError, ModelBase {
024
025    private String code;
026
027    private Map<String, java.lang.Object> values;
028
029    private com.commercetools.api.models.product.ProductReference product;
030
031    private com.commercetools.api.models.product_selection.ProductVariantSelection existingVariantSelection;
032
033    /**
034     * create instance with all properties
035     */
036    @JsonCreator
037    GraphQLProductPresentWithDifferentVariantSelectionErrorImpl(
038            @JsonProperty("values") final Map<String, java.lang.Object> values,
039            @JsonProperty("product") final com.commercetools.api.models.product.ProductReference product,
040            @JsonProperty("existingVariantSelection") final com.commercetools.api.models.product_selection.ProductVariantSelection existingVariantSelection) {
041        this.values = values;
042        this.product = product;
043        this.existingVariantSelection = existingVariantSelection;
044        this.code = PRODUCT_PRESENT_WITH_DIFFERENT_VARIANT_SELECTION;
045    }
046
047    /**
048     * create empty instance
049     */
050    public GraphQLProductPresentWithDifferentVariantSelectionErrorImpl() {
051        this.code = PRODUCT_PRESENT_WITH_DIFFERENT_VARIANT_SELECTION;
052    }
053
054    /**
055     *
056     */
057
058    public String getCode() {
059        return this.code;
060    }
061
062    /**
063     *  <p>Error-specific additional fields.</p>
064     */
065
066    public Map<String, java.lang.Object> values() {
067        return values;
068    }
069
070    /**
071     *  <p>Reference to the Product for which the error was returned.</p>
072     */
073
074    public com.commercetools.api.models.product.ProductReference getProduct() {
075        return this.product;
076    }
077
078    /**
079     *  <p>Existing Product Variant Selection or Exclusion for the Product in the Product Selection.</p>
080     */
081
082    public com.commercetools.api.models.product_selection.ProductVariantSelection getExistingVariantSelection() {
083        return this.existingVariantSelection;
084    }
085
086    public void setValue(String key, java.lang.Object value) {
087        if (values == null) {
088            values = new HashMap<>();
089        }
090        values.put(key, value);
091    }
092
093    public void setProduct(final com.commercetools.api.models.product.ProductReference product) {
094        this.product = product;
095    }
096
097    public void setExistingVariantSelection(
098            final com.commercetools.api.models.product_selection.ProductVariantSelection existingVariantSelection) {
099        this.existingVariantSelection = existingVariantSelection;
100    }
101
102    @Override
103    public boolean equals(Object o) {
104        if (this == o)
105            return true;
106
107        if (o == null || getClass() != o.getClass())
108            return false;
109
110        GraphQLProductPresentWithDifferentVariantSelectionErrorImpl that = (GraphQLProductPresentWithDifferentVariantSelectionErrorImpl) o;
111
112        return new EqualsBuilder().append(code, that.code)
113                .append(values, that.values)
114                .append(product, that.product)
115                .append(existingVariantSelection, that.existingVariantSelection)
116                .append(code, that.code)
117                .append(values, that.values)
118                .append(product, that.product)
119                .append(existingVariantSelection, that.existingVariantSelection)
120                .isEquals();
121    }
122
123    @Override
124    public int hashCode() {
125        return new HashCodeBuilder(17, 37).append(code)
126                .append(values)
127                .append(product)
128                .append(existingVariantSelection)
129                .toHashCode();
130    }
131
132}