001
002package com.commercetools.api.models.error;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007import java.util.stream.Collectors;
008
009import javax.annotation.Nullable;
010import javax.validation.Valid;
011import javax.validation.constraints.NotNull;
012
013import com.commercetools.api.models.product.Attribute;
014import com.fasterxml.jackson.annotation.*;
015import com.fasterxml.jackson.databind.annotation.*;
016
017import io.vrap.rmf.base.client.utils.Generated;
018
019/**
020 *  <p>Returned when the <code>CombinationUnique</code> AttributeConstraint criteria are not met during an Update Product request.</p>
021 *
022 * <hr>
023 * Example to create an instance using the builder pattern
024 * <div class=code-example>
025 * <pre><code class='java'>
026 *     GraphQLDuplicateAttributeValuesError graphQLDuplicateAttributeValuesError = GraphQLDuplicateAttributeValuesError.builder()
027 *             .plusAttributes(attributesBuilder -> attributesBuilder)
028 *             .build()
029 * </code></pre>
030 * </div>
031 */
032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
033@JsonDeserialize(as = GraphQLDuplicateAttributeValuesErrorImpl.class)
034public interface GraphQLDuplicateAttributeValuesError extends GraphQLErrorObject {
035
036    /**
037     * discriminator value for GraphQLDuplicateAttributeValuesError
038     */
039    String DUPLICATE_ATTRIBUTE_VALUES = "DuplicateAttributeValues";
040
041    /**
042     *
043     * @return code
044     */
045    @NotNull
046    @JsonProperty("code")
047    public String getCode();
048
049    /**
050     *  <p>Conflicting Attributes.</p>
051     * @return attributes
052     */
053    @NotNull
054    @Valid
055    @JsonProperty("attributes")
056    public List<Attribute> getAttributes();
057
058    /**
059     *  <p>Conflicting Attributes.</p>
060     * @param attributes values to be set
061     */
062
063    @JsonIgnore
064    public void setAttributes(final Attribute... attributes);
065
066    /**
067     *  <p>Conflicting Attributes.</p>
068     * @param attributes values to be set
069     */
070
071    public void setAttributes(final List<Attribute> attributes);
072
073    /**
074     * factory method
075     * @return instance of GraphQLDuplicateAttributeValuesError
076     */
077    public static GraphQLDuplicateAttributeValuesError of() {
078        return new GraphQLDuplicateAttributeValuesErrorImpl();
079    }
080
081    /**
082     * factory method to create a shallow copy GraphQLDuplicateAttributeValuesError
083     * @param template instance to be copied
084     * @return copy instance
085     */
086    public static GraphQLDuplicateAttributeValuesError of(final GraphQLDuplicateAttributeValuesError template) {
087        GraphQLDuplicateAttributeValuesErrorImpl instance = new GraphQLDuplicateAttributeValuesErrorImpl();
088        Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue));
089        instance.setAttributes(template.getAttributes());
090        return instance;
091    }
092
093    /**
094     * factory method to create a deep copy of GraphQLDuplicateAttributeValuesError
095     * @param template instance to be copied
096     * @return copy instance
097     */
098    @Nullable
099    public static GraphQLDuplicateAttributeValuesError deepCopy(
100            @Nullable final GraphQLDuplicateAttributeValuesError template) {
101        if (template == null) {
102            return null;
103        }
104        GraphQLDuplicateAttributeValuesErrorImpl instance = new GraphQLDuplicateAttributeValuesErrorImpl();
105        Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue));
106        instance.setAttributes(Optional.ofNullable(template.getAttributes())
107                .map(t -> t.stream()
108                        .map(com.commercetools.api.models.product.Attribute::deepCopy)
109                        .collect(Collectors.toList()))
110                .orElse(null));
111        return instance;
112    }
113
114    /**
115     * builder factory method for GraphQLDuplicateAttributeValuesError
116     * @return builder
117     */
118    public static GraphQLDuplicateAttributeValuesErrorBuilder builder() {
119        return GraphQLDuplicateAttributeValuesErrorBuilder.of();
120    }
121
122    /**
123     * create builder for GraphQLDuplicateAttributeValuesError instance
124     * @param template instance with prefilled values for the builder
125     * @return builder
126     */
127    public static GraphQLDuplicateAttributeValuesErrorBuilder builder(
128            final GraphQLDuplicateAttributeValuesError template) {
129        return GraphQLDuplicateAttributeValuesErrorBuilder.of(template);
130    }
131
132    /**
133     * accessor map function
134     * @param <T> mapped type
135     * @param helper function to map the object
136     * @return mapped value
137     */
138    default <T> T withGraphQLDuplicateAttributeValuesError(Function<GraphQLDuplicateAttributeValuesError, T> helper) {
139        return helper.apply(this);
140    }
141
142    /**
143     * gives a TypeReference for usage with Jackson DataBind
144     * @return TypeReference
145     */
146    public static com.fasterxml.jackson.core.type.TypeReference<GraphQLDuplicateAttributeValuesError> typeReference() {
147        return new com.fasterxml.jackson.core.type.TypeReference<GraphQLDuplicateAttributeValuesError>() {
148            @Override
149            public String toString() {
150                return "TypeReference<GraphQLDuplicateAttributeValuesError>";
151            }
152        };
153    }
154}