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