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.OptionalIterable;
20  import com.google.common.base.Objects;
21  
22  import javax.annotation.Nullable;
23  import java.net.URI;
24  import java.util.Collection;
25  
26  /**
27   * Complete information about single JIRA project.
28   * Many REST resources instead include just @{}BasicProject
29   *
30   * @since v0.1
31   */
32  public class Project extends BasicProject {
33  	@Nullable
34  	private final String description;
35  	private final BasicUser lead;
36  	@Nullable
37  	private final URI uri;
38  	private final Collection<Version> versions;
39  	private final Collection<BasicComponent> components;
40  	private final OptionalIterable<IssueType> issueTypes;
41  	private final Collection<BasicProjectRole> projectRoles;
42  
43  	public Project(URI self, String key, String name, String description, BasicUser lead, URI uri,
44  			Collection<Version> versions, Collection<BasicComponent> components,
45  			OptionalIterable<IssueType> issueTypes, Collection<BasicProjectRole> projectRoles) {
46  		super(self, key, name);
47  		this.description = description;
48  		this.lead = lead;
49  		this.uri = uri;
50  		this.versions = versions;
51  		this.components = components;
52  		this.issueTypes = issueTypes;
53  		this.projectRoles = projectRoles;
54  	}
55  
56  	/**
57  	 * @return description provided for this project or null if there is no description specific for this project.
58  	 */
59  	@Nullable
60  	public String getDescription() {
61  		return description;
62  	}
63  
64  	/**
65  	 * @return the person who leads this project
66  	 */
67  	public BasicUser getLead() {
68  		return lead;
69  	}
70  
71  	/**
72  	 * @return user-defined URI to a web page for this project, or <code>null</code> if not defined.
73  	 */
74  	@Nullable
75  	public URI getUri() {
76  		return uri;
77  	}
78  
79  	/**
80  	 * @return versions defined for this project
81  	 */
82  	public Iterable<Version> getVersions() {
83  		return versions;
84  	}
85  
86  	/**
87  	 * @return components defined for this project
88  	 */
89  	public Iterable<BasicComponent> getComponents() {
90  		return components;
91  	}
92  
93  	/**
94  	 * Getter for issueTypes
95  	 *
96  	 * @return the issueTypes defined for this project
97  	 */
98  	public OptionalIterable<IssueType> getIssueTypes() {
99  		return issueTypes;
100 	}
101 
102 	/**
103 	 * @return basic definition of this project's roles.
104 	 */
105 	public Iterable<BasicProjectRole> getProjectRoles() {
106 		return projectRoles;
107 	}
108 
109 	/**
110 	 * {@inheritDoc}
111 	 */
112 	@Override
113 	protected Objects.ToStringHelper getToStringHelper() {
114 		return super.getToStringHelper().
115 				add("description", description).
116 				add("lead", lead).
117 				add("uri", uri).
118 				add("components", components).
119 				add("issueTypes", issueTypes).
120 				add("versions", versions);
121 	}
122 
123 	@Override
124 	public boolean equals(Object o) {
125 		if (o instanceof Project) {
126 			Project that = (Project) o;
127 			return super.equals(that)
128 					&& Objects.equal(this.lead, that.lead)
129 					&& Objects.equal(this.uri, that.uri)
130 					&& Objects.equal(this.description, that.description)
131 					&& Objects.equal(this.components, that.components)
132 					&& Objects.equal(this.issueTypes, that.issueTypes)
133 					&& Objects.equal(this.versions, that.versions);
134 		}
135 		return false;
136 	}
137 
138 	@Override
139 	public int hashCode() {
140 		return Objects.hashCode(super.hashCode(), description, lead, uri);
141 	}
142 }