001
002package com.commercetools.api.models.graph_ql;
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.error.GraphQLErrorObject;
014import com.fasterxml.jackson.annotation.*;
015import com.fasterxml.jackson.databind.annotation.*;
016
017import io.vrap.rmf.base.client.utils.Generated;
018
019/**
020 * GraphQLError
021 *
022 * <hr>
023 * Example to create an instance using the builder pattern
024 * <div class=code-example>
025 * <pre><code class='java'>
026 *     GraphQLError graphQLError = GraphQLError.builder()
027 *             .message("{message}")
028 *             .plusLocations(locationsBuilder -> locationsBuilder)
029 *             .extensions(extensionsBuilder -> extensionsBuilder)
030 *             .build()
031 * </code></pre>
032 * </div>
033 */
034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
035@JsonDeserialize(as = GraphQLErrorImpl.class)
036public interface GraphQLError {
037
038    /**
039     *
040     * @return message
041     */
042    @NotNull
043    @JsonProperty("message")
044    public String getMessage();
045
046    /**
047     *
048     * @return locations
049     */
050    @NotNull
051    @Valid
052    @JsonProperty("locations")
053    public List<GraphQLErrorLocation> getLocations();
054
055    /**
056     *
057     * @return path
058     */
059
060    @JsonProperty("path")
061    public List<Object> getPath();
062
063    /**
064     *  <p>Represents a single error.</p>
065     * @return extensions
066     */
067    @NotNull
068    @Valid
069    @JsonProperty("extensions")
070    public GraphQLErrorObject getExtensions();
071
072    /**
073     * set message
074     * @param message value to be set
075     */
076
077    public void setMessage(final String message);
078
079    /**
080     * set locations
081     * @param locations values to be set
082     */
083
084    @JsonIgnore
085    public void setLocations(final GraphQLErrorLocation... locations);
086
087    /**
088     * set locations
089     * @param locations values to be set
090     */
091
092    public void setLocations(final List<GraphQLErrorLocation> locations);
093
094    /**
095     * set path
096     * @param path values to be set
097     */
098
099    @JsonIgnore
100    public void setPath(final Object... path);
101
102    /**
103     * set path
104     * @param path values to be set
105     */
106
107    public void setPath(final List<Object> path);
108
109    /**
110     *  <p>Represents a single error.</p>
111     * @param extensions value to be set
112     */
113
114    public void setExtensions(final GraphQLErrorObject extensions);
115
116    /**
117     * factory method
118     * @return instance of GraphQLError
119     */
120    public static GraphQLError of() {
121        return new GraphQLErrorImpl();
122    }
123
124    /**
125     * factory method to create a shallow copy GraphQLError
126     * @param template instance to be copied
127     * @return copy instance
128     */
129    public static GraphQLError of(final GraphQLError template) {
130        GraphQLErrorImpl instance = new GraphQLErrorImpl();
131        instance.setMessage(template.getMessage());
132        instance.setLocations(template.getLocations());
133        instance.setPath(template.getPath());
134        instance.setExtensions(template.getExtensions());
135        return instance;
136    }
137
138    /**
139     * factory method to create a deep copy of GraphQLError
140     * @param template instance to be copied
141     * @return copy instance
142     */
143    @Nullable
144    public static GraphQLError deepCopy(@Nullable final GraphQLError template) {
145        if (template == null) {
146            return null;
147        }
148        GraphQLErrorImpl instance = new GraphQLErrorImpl();
149        instance.setMessage(template.getMessage());
150        instance.setLocations(Optional.ofNullable(template.getLocations())
151                .map(t -> t.stream()
152                        .map(com.commercetools.api.models.graph_ql.GraphQLErrorLocation::deepCopy)
153                        .collect(Collectors.toList()))
154                .orElse(null));
155        instance.setPath(Optional.ofNullable(template.getPath()).map(ArrayList::new).orElse(null));
156        instance.setExtensions(
157            com.commercetools.api.models.error.GraphQLErrorObject.deepCopy(template.getExtensions()));
158        return instance;
159    }
160
161    /**
162     * builder factory method for GraphQLError
163     * @return builder
164     */
165    public static GraphQLErrorBuilder builder() {
166        return GraphQLErrorBuilder.of();
167    }
168
169    /**
170     * create builder for GraphQLError instance
171     * @param template instance with prefilled values for the builder
172     * @return builder
173     */
174    public static GraphQLErrorBuilder builder(final GraphQLError template) {
175        return GraphQLErrorBuilder.of(template);
176    }
177
178    /**
179     * accessor map function
180     * @param <T> mapped type
181     * @param helper function to map the object
182     * @return mapped value
183     */
184    default <T> T withGraphQLError(Function<GraphQLError, T> helper) {
185        return helper.apply(this);
186    }
187
188    /**
189     * gives a TypeReference for usage with Jackson DataBind
190     * @return TypeReference
191     */
192    public static com.fasterxml.jackson.core.type.TypeReference<GraphQLError> typeReference() {
193        return new com.fasterxml.jackson.core.type.TypeReference<GraphQLError>() {
194            @Override
195            public String toString() {
196                return "TypeReference<GraphQLError>";
197            }
198        };
199    }
200}