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.atlassian.jira.rest.client.api.AddressableEntity;
20  import com.atlassian.jira.rest.client.api.NamedEntity;
21  import com.google.common.base.Objects;
22  
23  import javax.annotation.Nullable;
24  import java.net.URI;
25  
26  /**
27   * Basic information about a JIRA project
28   *
29   * @since v0.1
30   */
31  public class BasicProject implements AddressableEntity, NamedEntity {
32  	private final URI self;
33  	private final String key;
34  	@Nullable
35  	private final String name;
36  
37  	public BasicProject(URI self, String key, String name) {
38  		this.self = self;
39  		this.key = key;
40  		this.name = name;
41  	}
42  
43  	@Override
44  	public URI getSelf() {
45  		return self;
46  	}
47  
48  	public String getKey() {
49  		return key;
50  	}
51  
52  	@Nullable
53  	public String getName() {
54  		return name;
55  	}
56  
57  	@Override
58  	public String toString() {
59  		return getToStringHelper().toString();
60  	}
61  
62  	protected Objects.ToStringHelper getToStringHelper() {
63  		return Objects.toStringHelper(this).
64  				add("self", self).
65  				add("key", key).
66  				add("name", name);
67  	}
68  
69  	@Override
70  	public boolean equals(Object obj) {
71  		if (obj instanceof BasicProject) {
72  			BasicProject that = (BasicProject) obj;
73  			return Objects.equal(this.self, that.self)
74  					&& Objects.equal(this.name, that.name)
75  					&& Objects.equal(this.key, that.key);
76  		}
77  		return false;
78  	}
79  
80  	@Override
81  	public int hashCode() {
82  		return Objects.hashCode(self, name, key);
83  	}
84  
85  }