View Javadoc

1   /*
2    * Copyright (C) 2011 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  import java.net.URI;
22  
23  /**
24   * Represents number of issues which use given version in their FixVersion(s) and Affects Version fields.
25   * This is mostly useful when presenting per-version basic issue stats or when about to remove given version completely.
26   *
27   * @since com.atlassian.jira.rest.client.api 0.3, server 4.4
28   */
29  public class VersionRelatedIssuesCount {
30  
31      private URI versionUri;
32  
33      private final int numFixedIssues;
34  
35      private final int numAffectedIssues;
36  
37      public VersionRelatedIssuesCount(URI versionUri, int numFixedIssues, int numAffectedIssues) {
38          this.versionUri = versionUri;
39          this.numAffectedIssues = numAffectedIssues;
40          this.numFixedIssues = numFixedIssues;
41      }
42  
43      /**
44       * @return link to Version entity this object describes issue stats for
45       */
46      public URI getVersionUri() {
47          return versionUri;
48      }
49  
50      /**
51       * @return number of issues which have this version set in their Fix Version(s) field
52       * (as a solely set version or one of multiple values set)
53       */
54      public int getNumFixedIssues() {
55          return numFixedIssues;
56      }
57  
58      /**
59       * @return number of issues which have this version set in their Affects Version(s) field
60       * (as a solely set version or one of multiple values set)
61       */
62      public int getNumAffectedIssues() {
63          return numAffectedIssues;
64      }
65  
66      @Override
67      public String toString() {
68          return Objects.toStringHelper(this).
69                  add("versionUri", versionUri).
70                  add("numFixedIssues", numFixedIssues).
71                  add("numAffectedIssues", numAffectedIssues).
72                  toString();
73      }
74  
75      @Override
76      public boolean equals(Object obj) {
77          if (obj instanceof VersionRelatedIssuesCount) {
78              VersionRelatedIssuesCount that = (VersionRelatedIssuesCount) obj;
79              return Objects.equal(this.numFixedIssues, that.numFixedIssues)
80                      && Objects.equal(this.versionUri, that.versionUri)
81                      && Objects.equal(this.numAffectedIssues, that.numAffectedIssues);
82          }
83          return false;
84      }
85  
86      @Override
87      public int hashCode() {
88          return Objects.hashCode(versionUri, numAffectedIssues, numFixedIssues);
89      }
90  
91  }