001package com.box.sdkgen.schemas.clienterror;
002
003import com.box.sdkgen.internal.Nullable;
004import com.box.sdkgen.internal.NullableFieldTracker;
005import com.box.sdkgen.internal.SerializableObject;
006import com.box.sdkgen.serialization.json.EnumWrapper;
007import com.fasterxml.jackson.annotation.JsonFilter;
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
010import com.fasterxml.jackson.databind.annotation.JsonSerialize;
011import java.util.Map;
012import java.util.Objects;
013
014/** A generic error. */
015@JsonFilter("nullablePropertyFilter")
016public class ClientError extends SerializableObject {
017
018  /** The value will always be `error`. */
019  @JsonDeserialize(using = ClientErrorTypeField.ClientErrorTypeFieldDeserializer.class)
020  @JsonSerialize(using = ClientErrorTypeField.ClientErrorTypeFieldSerializer.class)
021  protected EnumWrapper<ClientErrorTypeField> type;
022
023  /** The HTTP status of the response. */
024  protected Integer status;
025
026  /** A Box-specific error code. */
027  @JsonDeserialize(using = ClientErrorCodeField.ClientErrorCodeFieldDeserializer.class)
028  @JsonSerialize(using = ClientErrorCodeField.ClientErrorCodeFieldSerializer.class)
029  protected EnumWrapper<ClientErrorCodeField> code;
030
031  /** A short message describing the error. */
032  protected String message;
033
034  /**
035   * A free-form object that contains additional context about the error. The possible fields are
036   * defined on a per-endpoint basis. `message` is only one example.
037   */
038  @JsonProperty("context_info")
039  @Nullable
040  protected Map<String, Object> contextInfo;
041
042  /** A URL that links to more information about why this error occurred. */
043  @JsonProperty("help_url")
044  protected String helpUrl;
045
046  /** A unique identifier for this response, which can be used when contacting Box support. */
047  @JsonProperty("request_id")
048  protected String requestId;
049
050  public ClientError() {
051    super();
052  }
053
054  protected ClientError(Builder builder) {
055    super();
056    this.type = builder.type;
057    this.status = builder.status;
058    this.code = builder.code;
059    this.message = builder.message;
060    this.contextInfo = builder.contextInfo;
061    this.helpUrl = builder.helpUrl;
062    this.requestId = builder.requestId;
063    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
064  }
065
066  public EnumWrapper<ClientErrorTypeField> getType() {
067    return type;
068  }
069
070  public Integer getStatus() {
071    return status;
072  }
073
074  public EnumWrapper<ClientErrorCodeField> getCode() {
075    return code;
076  }
077
078  public String getMessage() {
079    return message;
080  }
081
082  public Map<String, Object> getContextInfo() {
083    return contextInfo;
084  }
085
086  public String getHelpUrl() {
087    return helpUrl;
088  }
089
090  public String getRequestId() {
091    return requestId;
092  }
093
094  @Override
095  public boolean equals(Object o) {
096    if (this == o) {
097      return true;
098    }
099    if (o == null || getClass() != o.getClass()) {
100      return false;
101    }
102    ClientError casted = (ClientError) o;
103    return Objects.equals(type, casted.type)
104        && Objects.equals(status, casted.status)
105        && Objects.equals(code, casted.code)
106        && Objects.equals(message, casted.message)
107        && Objects.equals(contextInfo, casted.contextInfo)
108        && Objects.equals(helpUrl, casted.helpUrl)
109        && Objects.equals(requestId, casted.requestId);
110  }
111
112  @Override
113  public int hashCode() {
114    return Objects.hash(type, status, code, message, contextInfo, helpUrl, requestId);
115  }
116
117  @Override
118  public String toString() {
119    return "ClientError{"
120        + "type='"
121        + type
122        + '\''
123        + ", "
124        + "status='"
125        + status
126        + '\''
127        + ", "
128        + "code='"
129        + code
130        + '\''
131        + ", "
132        + "message='"
133        + message
134        + '\''
135        + ", "
136        + "contextInfo='"
137        + contextInfo
138        + '\''
139        + ", "
140        + "helpUrl='"
141        + helpUrl
142        + '\''
143        + ", "
144        + "requestId='"
145        + requestId
146        + '\''
147        + "}";
148  }
149
150  public static class Builder extends NullableFieldTracker {
151
152    protected EnumWrapper<ClientErrorTypeField> type;
153
154    protected Integer status;
155
156    protected EnumWrapper<ClientErrorCodeField> code;
157
158    protected String message;
159
160    protected Map<String, Object> contextInfo;
161
162    protected String helpUrl;
163
164    protected String requestId;
165
166    public Builder type(ClientErrorTypeField type) {
167      this.type = new EnumWrapper<ClientErrorTypeField>(type);
168      return this;
169    }
170
171    public Builder type(EnumWrapper<ClientErrorTypeField> type) {
172      this.type = type;
173      return this;
174    }
175
176    public Builder status(Integer status) {
177      this.status = status;
178      return this;
179    }
180
181    public Builder code(ClientErrorCodeField code) {
182      this.code = new EnumWrapper<ClientErrorCodeField>(code);
183      return this;
184    }
185
186    public Builder code(EnumWrapper<ClientErrorCodeField> code) {
187      this.code = code;
188      return this;
189    }
190
191    public Builder message(String message) {
192      this.message = message;
193      return this;
194    }
195
196    public Builder contextInfo(Map<String, Object> contextInfo) {
197      this.contextInfo = contextInfo;
198      this.markNullableFieldAsSet("context_info");
199      return this;
200    }
201
202    public Builder helpUrl(String helpUrl) {
203      this.helpUrl = helpUrl;
204      return this;
205    }
206
207    public Builder requestId(String requestId) {
208      this.requestId = requestId;
209      return this;
210    }
211
212    public ClientError build() {
213      return new ClientError(this);
214    }
215  }
216}