View Javadoc

1   /*
2    * Copyright (C) 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.google.common.base.Objects;
20  
21  /**
22   * Basic representation of a JIRA issues and errors created using batch operation.
23   *
24   * @since v2.0
25   */
26  public class BulkOperationResult<T> {
27  
28      private final Iterable<T> issues;
29      private final Iterable<BulkOperationErrorResult> errors;
30  
31      public BulkOperationResult(final Iterable<T> issues, final Iterable<BulkOperationErrorResult> errors) {
32          this.issues = issues;
33          this.errors = errors;
34      }
35  
36      public Iterable<T> getIssues() {
37          return issues;
38      }
39  
40      public Iterable<BulkOperationErrorResult> getErrors() {
41          return errors;
42      }
43  
44      @Override
45      public String toString() {
46          return Objects.toStringHelper(this)
47                  .add("issues", issues)
48                  .add("errors", errors)
49                  .toString();
50      }
51  
52      @Override
53      public boolean equals(final Object obj) {
54          if (obj instanceof BulkOperationResult) {
55              final BulkOperationResult that = (BulkOperationResult) obj;
56              return Objects.equal(this.issues, that.issues)
57                      && Objects.equal(this.errors, that.errors);
58          }
59          return false;
60      }
61  
62      @Override
63      public int hashCode() {
64          return Objects.hashCode(issues, errors);
65      }
66  }