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.domain;
17  
18  import com.atlassian.jira.rest.client.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   * @see com.atlassian.jira.security.roles.ProjectRole
30   */
31  @SuppressWarnings("JavadocReference")
32  public class ProjectRole extends BasicProjectRole implements IdentifiableEntity<Long> {
33  
34  	private final String description;
35  	private final Collection<RoleActor> actors;
36  	private final long id;
37  
38  	public ProjectRole(long id, URI self, String name, String description, Collection<RoleActor> actors) {
39  		super(self, name);
40  		this.id = id;
41  		this.description = description;
42  		this.actors = actors;
43  	}
44  
45  	/**
46  	 * @return description of this project role.
47  	 */
48  	public String getDescription() {
49  		return description;
50  	}
51  
52  	/**
53  	 * @return actors associated with this role.
54  	 */
55  	public Iterable<RoleActor> getActors() {
56  		return actors;
57  	}
58  
59  	/**
60  	 * @return the unique id for this project role.
61  	 */
62  	public Long getId() {
63  		return id;
64  	}
65  
66  	@Override
67  	public boolean equals(Object o) {
68  		if (o instanceof ProjectRole) {
69  			final ProjectRole that = (ProjectRole) o;
70  			return super.equals(o)
71  					&& Objects.equal(this.description, that.description)
72  					&& Objects.equal(this.actors, that.actors)
73  					&& Objects.equal(this.id, that.id);
74  		}
75  		return false;
76  	}
77  
78  	@Override
79  	public int hashCode() {
80  		return Objects.hashCode(super.hashCode(), description, actors);
81  	}
82  
83  	@Override
84  	protected Objects.ToStringHelper getToStringHelper() {
85  		return super.getToStringHelper()
86  				.add("description", description)
87  				.add("actors", actors);
88  	}
89  }