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.atlassian.jira.rest.client.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 Objects.toStringHelper(this).
60  				add("self", self).
61  				add("key", key).
62  				add("name", name).
63  				toString();
64  	}
65  
66  	@Override
67  	public boolean equals(Object obj) {
68  		if (obj instanceof BasicProject) {
69  			BasicProject that = (BasicProject) obj;
70  			return Objects.equal(this.self, that.self)
71                      && Objects.equal(this.name, that.name)
72  					&& Objects.equal(this.key, that.key);
73  		}
74  		return false;
75  	}
76  
77  	@Override
78  	public int hashCode() {
79  		return Objects.hashCode(self, key);
80  	}
81  
82  }