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.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  	 *
66  	 * @return the person who leads this project
67  	 */
68  	public BasicUser getLead() {
69  		return lead;
70  	}
71  
72  	/**
73  	 * @return user-defined URI to a web page for this project, or <code>null</code> if not defined.
74  	 */
75  	@Nullable
76  	public URI getUri() {
77  		return uri;
78  	}
79  
80  	/**
81  	 * @return versions defined for this project
82  	 */
83  	public Iterable<Version> getVersions() {
84  		return versions;
85  	}
86  
87  	/**
88  	 *
89  	 * @return components defined for this project
90  	 */
91  	public Iterable<BasicComponent> getComponents() {
92  		return components;
93  	}
94  
95  	/**
96  	 * Getter for issueTypes
97  	 *
98  	 * @return the issueTypes defined for this project
99  	 */
100 	public OptionalIterable<IssueType> getIssueTypes() {
101 		return issueTypes;
102 	}
103 
104 	/**
105 	 * @return basic definition of this project's roles.
106 	 */
107 	public Iterable<BasicProjectRole> getProjectRoles() {
108 		return projectRoles;
109 	}
110 
111 	/**
112 	 * {@inheritDoc}
113 	 */
114 	@Override
115 	protected Objects.ToStringHelper getToStringHelper() {
116 		return super.getToStringHelper().
117 				add("description", description).
118 				add("lead", lead).
119 				add("uri", uri).
120 				add("components", components).
121 				add("issueTypes", issueTypes).
122 				add("versions", versions);
123 	}
124 
125 	@Override
126 	public boolean equals(Object o) {
127 		if (o instanceof Project) {
128 			Project that = (Project) o;
129 			return super.equals(that)
130 					&& Objects.equal(this.lead, that.lead)
131 					&& Objects.equal(this.uri, that.uri)
132 					&& Objects.equal(this.description, that.description)
133 					&& Objects.equal(this.components, that.components)
134 					&& Objects.equal(this.issueTypes, that.issueTypes)
135 					&& Objects.equal(this.versions, that.versions);
136 		}
137 		return false;
138 	}
139 
140 	@Override
141 	public int hashCode() {
142 		return Objects.hashCode(super.hashCode(), description, lead, uri);
143 	}
144 }