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