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