View Javadoc

1   /*
2    * Copyright (C) 2010-2012 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.jira.rest.client.api.domain;
18  
19  import com.atlassian.jira.rest.client.api.domain.util.ErrorCollection;
20  import com.google.common.base.Objects;
21  
22  /**
23   * Represents error of creating single element during batch operation.
24   *
25   * @since v1.1
26   */
27  
28  public class BulkOperationErrorResult {
29      private final ErrorCollection elementErrors;
30      private final Integer failedElementNumber;
31  
32      public BulkOperationErrorResult(final ErrorCollection errors, final Integer failedElementNumber) {
33          this.elementErrors = errors;
34          this.failedElementNumber = failedElementNumber;
35      }
36  
37      @SuppressWarnings("unused")
38      public ErrorCollection getElementErrors() {
39          return elementErrors;
40      }
41  
42      @SuppressWarnings("unused")
43      public Integer getFailedElementNumber() {
44          return failedElementNumber;
45      }
46  
47  
48      @Override
49      public String toString() {
50          return Objects.toStringHelper(this)
51                  .add("elementErrors", elementErrors)
52                  .add("failedElementNumber", failedElementNumber)
53                  .toString();
54  
55      }
56  
57      @Override
58      public boolean equals(final Object obj) {
59          if (obj instanceof BulkOperationErrorResult) {
60              final BulkOperationErrorResult that = (BulkOperationErrorResult) obj;
61              return Objects.equal(this.elementErrors, that.elementErrors)
62                      && Objects.equal(this.failedElementNumber, that.failedElementNumber);
63          }
64          return false;
65      }
66  
67      @Override
68      public int hashCode() {
69          return Objects.hashCode(elementErrors, failedElementNumber);
70      }
71  }