View Javadoc

1   /*
2    * Copyright (C) 2012 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.GetCreateIssueMetadataOptions;
20  import com.atlassian.jira.rest.client.api.IssueRestClient;
21  import com.google.common.base.Objects;
22  
23  import java.net.URI;
24  import java.util.Map;
25  
26  /**
27   * Represents project allowed to choose to create new issue. Also contains issue types allowed for that project described by {@link CimIssueType} class.<br/>
28   * The CIM prefix stands for CreateIssueMetadata as this class is used in output of {@link IssueRestClient#getCreateIssueMetadata(GetCreateIssueMetadataOptions, ProgressMonitor)}
29   *
30   * @since v1.0
31   */
32  public class CimProject extends BasicProject {
33  
34  	private final Map<String, URI> avatarUris;
35  	private final Iterable<CimIssueType> issueTypes;
36  
37  	public CimProject(URI self, String key, Long id, String name, Map<String, URI> avatarUris, Iterable<CimIssueType> issueTypes) {
38  		super(self, key, id, name);
39  		this.avatarUris = avatarUris;
40  		this.issueTypes = issueTypes;
41  	}
42  
43  	public Iterable<CimIssueType> getIssueTypes() {
44  		return issueTypes;
45  	}
46  
47  	public Map<String, URI> getAvatarUris() {
48  		return avatarUris;
49  	}
50  
51  	/**
52  	 * {@inheritDoc}
53  	 */
54  	@Override
55  	protected Objects.ToStringHelper getToStringHelper() {
56  		return super.getToStringHelper().
57  				add("issueTypes", issueTypes).
58  				add("avatarUris", avatarUris);
59  	}
60  
61  	@Override
62  	public int hashCode() {
63  		return Objects.hashCode(super.hashCode(), avatarUris, issueTypes);
64  	}
65  
66  	@Override
67  	public boolean equals(Object obj) {
68  		if (obj instanceof CimProject) {
69  			CimProject that = (CimProject) obj;
70  			return super.equals(obj)
71  					&& Objects.equal(this.avatarUris, that.avatarUris)
72  					&& Objects.equal(this.issueTypes, that.issueTypes);
73  		}
74  		return false;
75  	}
76  }