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.domain;
18  
19  import com.atlassian.jira.rest.client.AddressableEntity;
20  import com.google.common.base.Objects;
21  
22  import java.net.URI;
23  
24  /**
25   * Very basic (key and link only) representation of a JIRA issue.
26   *
27   * @since v0.2
28   */
29  public class BasicIssue implements AddressableEntity {
30  	private final URI self;
31  
32  	private final String key;
33  
34  	public BasicIssue(URI self, String key) {
35  		this.self = self;
36  		this.key = key;
37  	}
38  
39  	/**
40  	 * @return URI of this issue
41  	 */
42  	@Override
43  	public URI getSelf() {
44  		return self;
45  	}
46  
47  	/**
48  	 * @return issue key
49  	 */
50  	public String getKey() {
51  		return key;
52  	}
53  
54  	@Override
55  	public String toString() {
56  		return Objects.toStringHelper(this).
57  				add("self", self).
58  				add("key", key).
59  				toString();
60  	}
61  
62  	@Override
63  	public boolean equals(Object obj) {
64  		if (obj instanceof BasicIssue) {
65  			BasicIssue that = (BasicIssue) obj;
66  			return Objects.equal(this.self, that.self)
67  					&& Objects.equal(this.key, that.key);
68  		}
69  		return false;
70  	}
71  
72  	@Override
73  	public int hashCode() {
74  		return Objects.hashCode(self, key);
75  	}
76  
77  }