|
| 1 | +package com.xero.api; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | +import java.util.List; |
| 5 | +import java.util.Objects; |
| 6 | + |
| 7 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 8 | +import com.xero.models.accounting.Element; |
| 9 | +import com.xero.models.assets.FieldValidationErrorsElement; |
| 10 | +import com.xero.models.bankfeeds.FeedConnection; |
| 11 | +import com.xero.models.bankfeeds.FeedConnections; |
| 12 | +import com.xero.models.bankfeeds.Statement; |
| 13 | +import com.xero.models.bankfeeds.Statements; |
| 14 | + |
| 15 | +import io.swagger.annotations.ApiModelProperty; |
| 16 | + |
| 17 | +public class XeroConflictException extends XeroException { |
| 18 | + |
| 19 | + private static final long serialVersionUID = 1L; |
| 20 | + private Integer statusCode; |
| 21 | + private String type; |
| 22 | + private String message; |
| 23 | + private List<Element> elements = new ArrayList<Element>(); |
| 24 | + private List<Statement> statementItems = new ArrayList<Statement>(); |
| 25 | + private List<FeedConnection> feedConnectionItems = new ArrayList<FeedConnection>(); |
| 26 | + private List<FieldValidationErrorsElement> fieldValidationErrorsElements = new ArrayList<FieldValidationErrorsElement>(); |
| 27 | + private com.xero.models.payrolluk.Problem payrollUkProblem = new com.xero.models.payrolluk.Problem(); |
| 28 | + private com.xero.models.payrollnz.Problem payrollNzProblem = new com.xero.models.payrollnz.Problem(); |
| 29 | + |
| 30 | + |
| 31 | + public XeroConflictException(String objectType, com.xero.models.accounting.Error error) { |
| 32 | + this.statusCode = 409; |
| 33 | + this.type(objectType); |
| 34 | + this.elements(error.getElements()); |
| 35 | + } |
| 36 | + |
| 37 | + public XeroConflictException(String objectType, com.xero.models.assets.Error error) { |
| 38 | + this.statusCode = 409; |
| 39 | + this.type = objectType; |
| 40 | + this.fieldValidationErrorsElements = error.getFieldValidationErrors(); |
| 41 | + } |
| 42 | + |
| 43 | + public XeroConflictException(String objectType, Statements error) { |
| 44 | + this.statusCode = 409; |
| 45 | + this.type = objectType; |
| 46 | + this.statementItems = error.getItems(); |
| 47 | + } |
| 48 | + |
| 49 | + public XeroConflictException(String objectType, FeedConnections error) { |
| 50 | + this.statusCode = 409; |
| 51 | + this.type = objectType; |
| 52 | + this.feedConnectionItems = error.getItems(); |
| 53 | + } |
| 54 | + |
| 55 | + public XeroConflictException(String objectType, com.xero.models.payrolluk.Problem problem) { |
| 56 | + this.statusCode = 409; |
| 57 | + this.type = objectType; |
| 58 | + this.payrollUkProblem = problem; |
| 59 | + } |
| 60 | + |
| 61 | + public XeroConflictException(String objectType, com.xero.models.payrollnz.Problem problem) { |
| 62 | + this.statusCode = 409; |
| 63 | + this.type = objectType; |
| 64 | + this.payrollNzProblem = problem; |
| 65 | + } |
| 66 | + |
| 67 | + public XeroConflictException(Integer statusCode, String message) { |
| 68 | + this.statusCode = statusCode; |
| 69 | + this.message = message; |
| 70 | + } |
| 71 | + |
| 72 | + public XeroConflictException statusCode(Integer statusCode) { |
| 73 | + this.statusCode = statusCode; |
| 74 | + return this; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Exception number |
| 79 | + * @return statusCode |
| 80 | + **/ |
| 81 | + @ApiModelProperty(value = "Status Code") |
| 82 | + public Integer getStatusCode() { |
| 83 | + return statusCode; |
| 84 | + } |
| 85 | + |
| 86 | + public void setStatusCode(Integer statusCode) { |
| 87 | + this.statusCode = statusCode; |
| 88 | + } |
| 89 | + |
| 90 | + public XeroConflictException type(String type) { |
| 91 | + this.type = type; |
| 92 | + return this; |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Exception type |
| 97 | + * @return type |
| 98 | + **/ |
| 99 | + @ApiModelProperty(value = "API set type") |
| 100 | + public String getType() { |
| 101 | + return type; |
| 102 | + } |
| 103 | + |
| 104 | + public void setType(String type) { |
| 105 | + this.type = type; |
| 106 | + } |
| 107 | + |
| 108 | + public XeroConflictException message(String message) { |
| 109 | + this.message = message; |
| 110 | + return this; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Exception message |
| 115 | + * @return message |
| 116 | + **/ |
| 117 | + @ApiModelProperty(value = "Exception message") |
| 118 | + public String getMessage() { |
| 119 | + return message; |
| 120 | + } |
| 121 | + |
| 122 | + public void setMessage(String message) { |
| 123 | + this.message = message; |
| 124 | + } |
| 125 | + |
| 126 | + public XeroConflictException elements(List<Element> elements) { |
| 127 | + this.elements = elements; |
| 128 | + return this; |
| 129 | + } |
| 130 | + |
| 131 | + public XeroConflictException addElementsItem(Element elementsItem) { |
| 132 | + if (this.elements == null) { |
| 133 | + this.elements = new ArrayList<Element>(); |
| 134 | + } |
| 135 | + this.elements.add(elementsItem); |
| 136 | + return this; |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Array of Elements of validation Errors |
| 141 | + * @return elements |
| 142 | + **/ |
| 143 | + @ApiModelProperty(value = "Array of Elements of validation Errors") |
| 144 | + public List<Element> getElements() { |
| 145 | + return elements; |
| 146 | + } |
| 147 | + |
| 148 | + public void setElements(List<Element> elements) { |
| 149 | + this.elements = elements; |
| 150 | + } |
| 151 | + |
| 152 | + // Bank Feed Statement items |
| 153 | + public XeroConflictException statementItems(List<Statement> statementItems) { |
| 154 | + this.statementItems = statementItems; |
| 155 | + return this; |
| 156 | + } |
| 157 | + |
| 158 | + public XeroConflictException addStatementItem(Statement item) { |
| 159 | + if (this.statementItems == null) { |
| 160 | + this.statementItems = new ArrayList<Statement>(); |
| 161 | + } |
| 162 | + this.statementItems.add(item); |
| 163 | + return this; |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Array of Statements Items of Errors Array |
| 168 | + * @return statementItems |
| 169 | + **/ |
| 170 | + @ApiModelProperty(value = "Array of Statement Items with Errors Array") |
| 171 | + public List<Statement> getStatementItems() { |
| 172 | + return statementItems; |
| 173 | + } |
| 174 | + |
| 175 | + public void setStatementItems(List<Statement> statementItems) { |
| 176 | + this.statementItems = statementItems; |
| 177 | + } |
| 178 | + |
| 179 | + // Bank Feed FeedConnection items |
| 180 | + public XeroConflictException feedConnectionItems(List<FeedConnection> feedConnectionItems) { |
| 181 | + this.feedConnectionItems = feedConnectionItems; |
| 182 | + return this; |
| 183 | + } |
| 184 | + |
| 185 | + public XeroConflictException addFeedConnectionItems(FeedConnection item) { |
| 186 | + if (this.feedConnectionItems == null) { |
| 187 | + this.feedConnectionItems = new ArrayList<FeedConnection>(); |
| 188 | + } |
| 189 | + this.feedConnectionItems.add(item); |
| 190 | + return this; |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Array of FeedConnection of Errors Array |
| 195 | + * @return statementItems |
| 196 | + **/ |
| 197 | + @ApiModelProperty(value = "Array of FeedConnection Items with Errors Array") |
| 198 | + public List<FeedConnection> getFeedConnectionItems() { |
| 199 | + return feedConnectionItems; |
| 200 | + } |
| 201 | + |
| 202 | + public void setFeedConnectionItems(List<FeedConnection> feedConnectionItems) { |
| 203 | + this.feedConnectionItems = feedConnectionItems; |
| 204 | + } |
| 205 | + |
| 206 | + // Assets field Validation Errors |
| 207 | + public XeroConflictException fieldValidationErrorsElements(List<FieldValidationErrorsElement> fieldValidationErrorsElements) { |
| 208 | + this.fieldValidationErrorsElements = fieldValidationErrorsElements; |
| 209 | + return this; |
| 210 | + } |
| 211 | + |
| 212 | + public XeroConflictException addFieldValidationErrorsElement(FieldValidationErrorsElement element) { |
| 213 | + if (this.fieldValidationErrorsElements == null) { |
| 214 | + this.fieldValidationErrorsElements = new ArrayList<FieldValidationErrorsElement>(); |
| 215 | + } |
| 216 | + this.fieldValidationErrorsElements.add(element); |
| 217 | + return this; |
| 218 | + } |
| 219 | + |
| 220 | + /** |
| 221 | + * Array of Assets Errors Array |
| 222 | + * @return statementItems |
| 223 | + **/ |
| 224 | + @ApiModelProperty(value = "Array of FieldValidationErrorElement") |
| 225 | + public List<FieldValidationErrorsElement> getFieldValidationErrorsElements() { |
| 226 | + return fieldValidationErrorsElements; |
| 227 | + } |
| 228 | + |
| 229 | + public void setFieldValidationErrorsElements(List<FieldValidationErrorsElement> fieldValidationErrorsElements) { |
| 230 | + this.fieldValidationErrorsElements = fieldValidationErrorsElements; |
| 231 | + } |
| 232 | + |
| 233 | + |
| 234 | + // NZ Payroll Problems Errors |
| 235 | + public XeroConflictException payrollNzProblem(com.xero.models.payrollnz.Problem problem) { |
| 236 | + this.payrollNzProblem = problem; |
| 237 | + return this; |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * Exception type |
| 242 | + * @return com.xero.models.payrolluk.Problem |
| 243 | + **/ |
| 244 | + @ApiModelProperty(value = "NZ Payroll problem") |
| 245 | + public com.xero.models.payrollnz.Problem getPayrollNzProblem() { |
| 246 | + return payrollNzProblem; |
| 247 | + } |
| 248 | + |
| 249 | + public void setPayrollNzProblem(com.xero.models.payrollnz.Problem problem) { |
| 250 | + this.payrollNzProblem = problem; |
| 251 | + } |
| 252 | + |
| 253 | + |
| 254 | + // UK Payroll Problems Errors |
| 255 | + public XeroConflictException payrollUkProblem(com.xero.models.payrolluk.Problem problem) { |
| 256 | + this.payrollUkProblem = problem; |
| 257 | + return this; |
| 258 | + } |
| 259 | + |
| 260 | + /** |
| 261 | + * Exception type |
| 262 | + * @return com.xero.models.payrolluk.Problem |
| 263 | + **/ |
| 264 | + @ApiModelProperty(value = "UK Payroll problem") |
| 265 | + public com.xero.models.payrolluk.Problem getPayrollUkProblem() { |
| 266 | + return payrollUkProblem; |
| 267 | + } |
| 268 | + |
| 269 | + public void setPayrollUkProblem(com.xero.models.payrolluk.Problem problem) { |
| 270 | + this.payrollUkProblem = problem; |
| 271 | + } |
| 272 | + |
| 273 | + @Override |
| 274 | + public boolean equals(java.lang.Object o) { |
| 275 | + if (this == o) { |
| 276 | + return true; |
| 277 | + } |
| 278 | + if (o == null || getClass() != o.getClass()) { |
| 279 | + return false; |
| 280 | + } |
| 281 | + XeroConflictException error = (XeroConflictException) o; |
| 282 | + return Objects.equals(this.statusCode, error.statusCode) && |
| 283 | + Objects.equals(this.type, error.type) && |
| 284 | + Objects.equals(this.message, error.message) && |
| 285 | + Objects.equals(this.elements, error.elements); |
| 286 | + } |
| 287 | + |
| 288 | + @Override |
| 289 | + public int hashCode() { |
| 290 | + return Objects.hash(statusCode, type, message); //, elements |
| 291 | + } |
| 292 | + |
| 293 | + |
| 294 | + @Override |
| 295 | + public String toString() { |
| 296 | + StringBuilder sb = new StringBuilder(); |
| 297 | + sb.append("class Error {\n"); |
| 298 | + sb.append(" statusCode: ").append(toIndentedString(statusCode)).append("\n"); |
| 299 | + sb.append(" type: ").append(toIndentedString(type)).append("\n"); |
| 300 | + sb.append(" message: ").append(toIndentedString(message)).append("\n"); |
| 301 | + sb.append(" elements: ").append(toIndentedString(elements)).append("\n"); |
| 302 | + sb.append("}"); |
| 303 | + return sb.toString(); |
| 304 | + } |
| 305 | + |
| 306 | + /** |
| 307 | + * Convert the given object to string with each line indented by 4 spaces |
| 308 | + * (except the first line). |
| 309 | + */ |
| 310 | + private String toIndentedString(java.lang.Object o) { |
| 311 | + if (o == null) { |
| 312 | + return "null"; |
| 313 | + } |
| 314 | + return o.toString().replace("\n", "\n "); |
| 315 | + } |
| 316 | + |
| 317 | +} |
0 commit comments