001
002package com.commercetools.api.models.error;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007
008import javax.annotation.Nullable;
009import javax.validation.constraints.NotNull;
010
011import com.fasterxml.jackson.annotation.*;
012import com.fasterxml.jackson.databind.annotation.*;
013
014import io.vrap.rmf.base.client.utils.Generated;
015
016/**
017 *  <p>Returned when an enum value cannot be removed from an Attribute as it is being used by a Product.</p>
018 *  <p>The error is returned as a failed response to the Remove EnumValues from AttributeDefinition update action.</p>
019 *
020 * <hr>
021 * Example to create an instance using the builder pattern
022 * <div class=code-example>
023 * <pre><code class='java'>
024 *     GraphQLEnumValueIsUsedError graphQLEnumValueIsUsedError = GraphQLEnumValueIsUsedError.builder()
025 *             .build()
026 * </code></pre>
027 * </div>
028 */
029@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
030@JsonDeserialize(as = GraphQLEnumValueIsUsedErrorImpl.class)
031public interface GraphQLEnumValueIsUsedError extends GraphQLErrorObject {
032
033    /**
034     * discriminator value for GraphQLEnumValueIsUsedError
035     */
036    String ENUM_VALUE_IS_USED = "EnumValueIsUsed";
037
038    /**
039     *
040     * @return code
041     */
042    @NotNull
043    @JsonProperty("code")
044    public String getCode();
045
046    /**
047     * factory method
048     * @return instance of GraphQLEnumValueIsUsedError
049     */
050    public static GraphQLEnumValueIsUsedError of() {
051        return new GraphQLEnumValueIsUsedErrorImpl();
052    }
053
054    /**
055     * factory method to create a shallow copy GraphQLEnumValueIsUsedError
056     * @param template instance to be copied
057     * @return copy instance
058     */
059    public static GraphQLEnumValueIsUsedError of(final GraphQLEnumValueIsUsedError template) {
060        GraphQLEnumValueIsUsedErrorImpl instance = new GraphQLEnumValueIsUsedErrorImpl();
061        Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue));
062        return instance;
063    }
064
065    /**
066     * factory method to create a deep copy of GraphQLEnumValueIsUsedError
067     * @param template instance to be copied
068     * @return copy instance
069     */
070    @Nullable
071    public static GraphQLEnumValueIsUsedError deepCopy(@Nullable final GraphQLEnumValueIsUsedError template) {
072        if (template == null) {
073            return null;
074        }
075        GraphQLEnumValueIsUsedErrorImpl instance = new GraphQLEnumValueIsUsedErrorImpl();
076        Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue));
077        return instance;
078    }
079
080    /**
081     * builder factory method for GraphQLEnumValueIsUsedError
082     * @return builder
083     */
084    public static GraphQLEnumValueIsUsedErrorBuilder builder() {
085        return GraphQLEnumValueIsUsedErrorBuilder.of();
086    }
087
088    /**
089     * create builder for GraphQLEnumValueIsUsedError instance
090     * @param template instance with prefilled values for the builder
091     * @return builder
092     */
093    public static GraphQLEnumValueIsUsedErrorBuilder builder(final GraphQLEnumValueIsUsedError template) {
094        return GraphQLEnumValueIsUsedErrorBuilder.of(template);
095    }
096
097    /**
098     * accessor map function
099     * @param <T> mapped type
100     * @param helper function to map the object
101     * @return mapped value
102     */
103    default <T> T withGraphQLEnumValueIsUsedError(Function<GraphQLEnumValueIsUsedError, T> helper) {
104        return helper.apply(this);
105    }
106
107    /**
108     * gives a TypeReference for usage with Jackson DataBind
109     * @return TypeReference
110     */
111    public static com.fasterxml.jackson.core.type.TypeReference<GraphQLEnumValueIsUsedError> typeReference() {
112        return new com.fasterxml.jackson.core.type.TypeReference<GraphQLEnumValueIsUsedError>() {
113            @Override
114            public String toString() {
115                return "TypeReference<GraphQLEnumValueIsUsedError>";
116            }
117        };
118    }
119}