View Javadoc

1   /*
2    * Copyright (C) 2010 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   * Link between two JIRA issues
25   *
26   * @since v0.1
27   */
28  public class IssueLink {
29      private final String targetIssueKey;
30      private final URI targetIssueUri;
31      private final IssueLinkType issueLinkType;
32  
33      public IssueLink(String targetIssueKey, URI targetIssueUri, IssueLinkType issueLinkType) {
34          this.targetIssueKey = targetIssueKey;
35          this.targetIssueUri = targetIssueUri;
36          this.issueLinkType = issueLinkType;
37      }
38  
39      public String getTargetIssueKey() {
40          return targetIssueKey;
41      }
42  
43      public URI getTargetIssueUri() {
44          return targetIssueUri;
45      }
46  
47      public IssueLinkType getIssueLinkType() {
48          return issueLinkType;
49      }
50  
51      @Override
52      public String toString() {
53          return Objects.toStringHelper(this).
54                  add("targetIssueKey", targetIssueKey).
55                  add("targetIssueUri", targetIssueUri).
56                  add("issueLinkType", issueLinkType).
57                  toString();
58      }
59  
60      @Override
61      public boolean equals(Object obj) {
62          if (obj instanceof IssueLink) {
63              IssueLink that = (IssueLink) obj;
64              return Objects.equal(this.targetIssueKey, that.targetIssueKey)
65                      && Objects.equal(this.targetIssueUri, that.targetIssueUri)
66                      && Objects.equal(this.issueLinkType, that.issueLinkType);
67          }
68          return false;
69      }
70  
71      @Override
72      public int hashCode() {
73          return Objects.hashCode(targetIssueKey, targetIssueUri, issueLinkType);
74      }
75  
76  }