Package com.alpaca.entity
Class Role
java.lang.Object
com.alpaca.entity.Role
Represents a Role entity in the system. This entity is mapped to the "roles" table in the
database and defines user roles with specific permissions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate UUID
Unique identifier for the Role.private String
A brief description of the Role.private String
The name of the Role.private Set
<RolePermission> Indicates the set of Permission has the Role.Indicates the set of User has the Role. -
Constructor Summary
ConstructorsConstructorDescriptionRole
(String roleName, String roleDescription, Set<Permission> permissions) Constructs an instance of a new Role object with the specified attributes. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Retrieves the list of permissions assigned to this Role.int
hashCode()
permissionsToRolePermissions
(Collection<Permission> permissions) Converts a set ofPermission
objects into a set ofRolePermission
objects associated with this Role.void
setRolePermissions
(Collection<Permission> permissions)
-
Field Details
-
id
Unique identifier for the Role. This value is automatically generated using a UUID strategy. -
roleName
The name of the Role. This field is unique and cannot be null. -
roleDescription
A brief description of the Role. This field is unique and cannot be null. -
rolePermissions
Indicates the set of Permission has the Role.A Role has a many-to-many relationship with an
Permission
throughRolePermission
-
userRoles
-
-
Constructor Details
-
Role
Constructs an instance of a new Role object with the specified attributes. The generated object is ready to be used and stored in the database.- Parameters:
roleName
- Name of the Role - must not be nullroleDescription
- Short description of the Role - must not be nullpermissions
- Set of permissions associated with this Role
-
-
Method Details
-
setRolePermissions
-
permissionsToRolePermissions
Converts a set ofPermission
objects into a set ofRolePermission
objects associated with this Role.- Parameters:
permissions
- the set ofPermission
objects to be converted.- Returns:
- a set of
RolePermission
objects associated with this Role.
-
getPermissions
Retrieves the list of permissions assigned to this Role.- Returns:
- a list of
Permission
objects associated with this Role.
-
equals
-
hashCode
public int hashCode()
-