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 the Cart contains a ShippingMethod that is not allowed for the Cart. In this case, the ShippingMethodState value is <code>DoesNotMatchCart</code>.</p>
018 *  <p>The error is returned as a failed response to the Create Order from Cart or Create Order in Store from Cart requests.</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 *     GraphQLShippingMethodDoesNotMatchCartError graphQLShippingMethodDoesNotMatchCartError = GraphQLShippingMethodDoesNotMatchCartError.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 = GraphQLShippingMethodDoesNotMatchCartErrorImpl.class)
031public interface GraphQLShippingMethodDoesNotMatchCartError extends GraphQLErrorObject {
032
033    /**
034     * discriminator value for GraphQLShippingMethodDoesNotMatchCartError
035     */
036    String SHIPPING_METHOD_DOES_NOT_MATCH_CART = "ShippingMethodDoesNotMatchCart";
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 GraphQLShippingMethodDoesNotMatchCartError
049     */
050    public static GraphQLShippingMethodDoesNotMatchCartError of() {
051        return new GraphQLShippingMethodDoesNotMatchCartErrorImpl();
052    }
053
054    /**
055     * factory method to create a shallow copy GraphQLShippingMethodDoesNotMatchCartError
056     * @param template instance to be copied
057     * @return copy instance
058     */
059    public static GraphQLShippingMethodDoesNotMatchCartError of(
060            final GraphQLShippingMethodDoesNotMatchCartError template) {
061        GraphQLShippingMethodDoesNotMatchCartErrorImpl instance = new GraphQLShippingMethodDoesNotMatchCartErrorImpl();
062        Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue));
063        return instance;
064    }
065
066    /**
067     * factory method to create a deep copy of GraphQLShippingMethodDoesNotMatchCartError
068     * @param template instance to be copied
069     * @return copy instance
070     */
071    @Nullable
072    public static GraphQLShippingMethodDoesNotMatchCartError deepCopy(
073            @Nullable final GraphQLShippingMethodDoesNotMatchCartError template) {
074        if (template == null) {
075            return null;
076        }
077        GraphQLShippingMethodDoesNotMatchCartErrorImpl instance = new GraphQLShippingMethodDoesNotMatchCartErrorImpl();
078        Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue));
079        return instance;
080    }
081
082    /**
083     * builder factory method for GraphQLShippingMethodDoesNotMatchCartError
084     * @return builder
085     */
086    public static GraphQLShippingMethodDoesNotMatchCartErrorBuilder builder() {
087        return GraphQLShippingMethodDoesNotMatchCartErrorBuilder.of();
088    }
089
090    /**
091     * create builder for GraphQLShippingMethodDoesNotMatchCartError instance
092     * @param template instance with prefilled values for the builder
093     * @return builder
094     */
095    public static GraphQLShippingMethodDoesNotMatchCartErrorBuilder builder(
096            final GraphQLShippingMethodDoesNotMatchCartError template) {
097        return GraphQLShippingMethodDoesNotMatchCartErrorBuilder.of(template);
098    }
099
100    /**
101     * accessor map function
102     * @param <T> mapped type
103     * @param helper function to map the object
104     * @return mapped value
105     */
106    default <T> T withGraphQLShippingMethodDoesNotMatchCartError(
107            Function<GraphQLShippingMethodDoesNotMatchCartError, T> helper) {
108        return helper.apply(this);
109    }
110
111    /**
112     * gives a TypeReference for usage with Jackson DataBind
113     * @return TypeReference
114     */
115    public static com.fasterxml.jackson.core.type.TypeReference<GraphQLShippingMethodDoesNotMatchCartError> typeReference() {
116        return new com.fasterxml.jackson.core.type.TypeReference<GraphQLShippingMethodDoesNotMatchCartError>() {
117            @Override
118            public String toString() {
119                return "TypeReference<GraphQLShippingMethodDoesNotMatchCartError>";
120            }
121        };
122    }
123}