public class Role extends java.lang.Object implements java.lang.Comparable<Role>
Modifier and Type | Class and Description |
---|---|
static interface |
Role.PermissionMergeStrategy
Takes a set of existing permissions and a set of new permissions and
decides how to combine them into a result set.
|
Modifier and Type | Field and Description |
---|---|
static Role.PermissionMergeStrategy |
ADDING_STRATEGY
Returns the result of adding
newPermissions to
existingPermissions . |
static com.google.common.base.Function<Role,java.lang.String> |
asRoleName |
static Role.PermissionMergeStrategy |
REMOVING_STRATEGY
Returns the result of removing
newPermissions from existingPermissions . |
static Role.PermissionMergeStrategy |
REPLACING_STRATEGY
Returns
newPermissions . |
Constructor and Description |
---|
Role() |
Role(Role r)
Copy constructor.
|
Role(java.lang.String name)
Creates a role with the given name and empty id/uuid sets.
|
Role(java.lang.String name,
java.util.Set<java.lang.String> usernames,
java.util.Set<java.lang.Long> groupIds,
java.util.Set<java.lang.String> userUuids,
java.util.Set<java.lang.String> groupUuids)
Creates a role with the given name and the given ids/uuids.
|
Role(java.lang.String name,
java.lang.String[] usernames,
java.lang.Long[] groupIds)
Creates a role with the given name and the given ids/uuids.
|
Role(java.lang.String name,
java.lang.String[] usernames,
java.lang.Long[] groupIds,
java.lang.String[] userUuids,
java.lang.String[] groupUuids)
Creates a role with the given name and the given ids/uuids.
|
Modifier and Type | Method and Description |
---|---|
static java.util.Set<Role> |
addPermissions(java.util.Set<Role> existingPermissions,
java.util.Set<Role> permissionsToAdd)
Returns a new
Set<Role> with permissions (groups and users) from
permissionsToAdd added to existingPermissions . |
static Role |
applyRole(Role existingRole,
Role newRole,
Role.PermissionMergeStrategy strategy)
Returns a new
Role that is the result of applying the
strategy to existingRole and newRole . |
static java.util.Set<Role> |
applyRoleMap(java.util.Set<Role> existingRoleMap,
java.util.Set<Role> newRoleMap,
Role.PermissionMergeStrategy strategy)
Returns a new
Set<Role> that is the result of applying the
permission strategy to matching pairs of Role s from
existingRoleMap and newRoleMap . |
int |
compareTo(Role otherRole) |
boolean |
equals(java.lang.Object obj)
Returns true if the given object is a non-null Role object that has the same name
as this Role.
|
java.util.Set<java.lang.Long> |
getGroupIds()
Returns the ids of the groups that have this role.
|
java.util.Set<java.lang.String> |
getGroupUuids()
Returns the UUIDs of the groups that have this role.
|
java.lang.String |
getName()
Returns the name of this role.
|
java.util.Set<java.lang.String> |
getUsernames()
Returns the usernames of the users that have this role.
|
java.util.Set<java.lang.String> |
getUserUuids()
Returns the UUIDs of the users that have this role.
|
int |
hashCode()
Returns the hash code for this Role, calculated as the hash code of this Role's name.
|
static java.util.Set<Role> |
removePermissions(java.util.Set<Role> existingPermissions,
java.util.Set<Role> permissionsToRemove)
Returns a new
Set<Role> with permissions (groups and users) from
permissionsToRemove removed from existingPermissions . |
void |
setGroupIds(java.util.Set<java.lang.Long> groupIds) |
void |
setGroupUuids(java.util.Set<java.lang.String> groupUuids) |
void |
setName(java.lang.String name) |
void |
setUsernames(java.util.Set<java.lang.String> userIds) |
void |
setUserUuids(java.util.Set<java.lang.String> userUuids) |
java.lang.String |
toString() |
public static final com.google.common.base.Function<Role,java.lang.String> asRoleName
public static final Role.PermissionMergeStrategy ADDING_STRATEGY
newPermissions
to
existingPermissions
. If any new permissions already exist, they are
ignored.public static final Role.PermissionMergeStrategy REMOVING_STRATEGY
newPermissions
from existingPermissions
.public static final Role.PermissionMergeStrategy REPLACING_STRATEGY
newPermissions
.public Role()
public Role(java.lang.String name)
public Role(java.lang.String name, java.util.Set<java.lang.String> usernames, java.util.Set<java.lang.Long> groupIds, java.util.Set<java.lang.String> userUuids, java.util.Set<java.lang.String> groupUuids)
null
is passed in for one of the
sets, the role will use a new empty set instead.public Role(java.lang.String name, java.lang.String[] usernames, java.lang.Long[] groupIds)
public Role(java.lang.String name, java.lang.String[] usernames, java.lang.Long[] groupIds, java.lang.String[] userUuids, java.lang.String[] groupUuids)
public Role(Role r)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
public void setName(java.lang.String name)
public java.util.Set<java.lang.String> getUsernames()
public void setUsernames(java.util.Set<java.lang.String> userIds)
public java.util.Set<java.lang.String> getUserUuids()
public void setUserUuids(java.util.Set<java.lang.String> userUuids)
public java.util.Set<java.lang.Long> getGroupIds()
public void setGroupIds(java.util.Set<java.lang.Long> groupIds)
public java.util.Set<java.lang.String> getGroupUuids()
public void setGroupUuids(java.util.Set<java.lang.String> groupUuids)
public int compareTo(Role otherRole)
compareTo
in interface java.lang.Comparable<Role>
public static java.util.Set<Role> addPermissions(java.util.Set<Role> existingPermissions, java.util.Set<Role> permissionsToAdd)
Set<Role>
with permissions (groups and users) from
permissionsToAdd
added to existingPermissions
.public static java.util.Set<Role> removePermissions(java.util.Set<Role> existingPermissions, java.util.Set<Role> permissionsToRemove)
Set<Role>
with permissions (groups and users) from
permissionsToRemove
removed from existingPermissions
.public static java.util.Set<Role> applyRoleMap(java.util.Set<Role> existingRoleMap, java.util.Set<Role> newRoleMap, Role.PermissionMergeStrategy strategy)
Set<Role>
that is the result of applying the
permission strategy
to matching pairs of Role
s from
existingRoleMap
and newRoleMap
. Role
s are matched
up by role name.public static Role applyRole(Role existingRole, Role newRole, Role.PermissionMergeStrategy strategy)
Role
that is the result of applying the
strategy
to existingRole
and newRole
. For example,
if the strategy was ADDING_STRATEGY
, this would return a new
Role
with the groups and users of both newRole
and
existingRole
.Copyright © 2003-2024 Appian Corporation. All Rights Reserved.