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  package com.atlassian.jira.rest.client.api.domain;
17  
18  import com.atlassian.jira.rest.client.api.IdentifiableEntity;
19  import com.google.common.base.Objects;
20  
21  import java.net.URI;
22  import java.util.Collection;
23  
24  /**
25   * A way to group users (@see RoleActors) with projects. An example would be a global role called "testers". If you
26   * have a project X and a project Y, you would then be able to configure different RoleActors in the "testers" role
27   * for project X than for project Y. You can use ProjectRole objects as the target of Notification and Permission
28   * schemes.
29   *
30   * @see com.atlassian.jira.security.roles.ProjectRole
31   */
32  @SuppressWarnings("JavadocReference")
33  public class ProjectRole extends BasicProjectRole implements IdentifiableEntity<Long> {
34  
35  	private final String description;
36  	private final Collection<RoleActor> actors;
37  	private final long id;
38  
39  	public ProjectRole(long id, URI self, String name, String description, Collection<RoleActor> actors) {
40  		super(self, name);
41  		this.id = id;
42  		this.description = description;
43  		this.actors = actors;
44  	}
45  
46  	/**
47  	 * @return description of this project role.
48  	 */
49  	public String getDescription() {
50  		return description;
51  	}
52  
53  	/**
54  	 * @return actors associated with this role.
55  	 */
56  	public Iterable<RoleActor> getActors() {
57  		return actors;
58  	}
59  
60  	/**
61  	 * @return the unique id for this project role.
62  	 */
63  	public Long getId() {
64  		return id;
65  	}
66  
67  	@Override
68  	public boolean equals(Object o) {
69  		if (o instanceof ProjectRole) {
70  			final ProjectRole that = (ProjectRole) o;
71  			return super.equals(o)
72  					&& Objects.equal(this.description, that.description)
73  					&& Objects.equal(this.actors, that.actors)
74  					&& Objects.equal(this.id, that.id);
75  		}
76  		return false;
77  	}
78  
79  	@Override
80  	public int hashCode() {
81  		return Objects.hashCode(super.hashCode(), description, actors);
82  	}
83  
84  	@Override
85  	protected Objects.ToStringHelper getToStringHelper() {
86  		return super.getToStringHelper()
87  				.add("description", description)
88  				.add("actors", actors);
89  	}
90  }