public class PermissionField extends RoleField<java.lang.Long>
Permission
depending Field.
The specification for this Field will automatically check provided
Permissions
for access by using
PermissionUtil.checkPermission(Member, Permission...)
on the current account's Member instance for the specified Guild
.
This class is an extension of RoleField
It provides specific convenience Methods to modify the Permissions for a Role or equal.
Constructor and Description |
---|
PermissionField(RoleManagerUpdatable manager,
java.util.function.Supplier<java.lang.Long> originalValue) |
Modifier and Type | Method and Description |
---|---|
void |
checkValue(java.lang.Long value)
Hook method for custom value verification.
|
java.util.List<Permission> |
getOriginalPermissions()
An immutable list of
Permissions
that have been calculated Field.getOriginalValue() using Permission.getPermissions(long) |
java.util.List<Permission> |
getPermissions()
An immutable list of
Permissions
that are calculated from getValue() using Permission.getPermissions(long) |
java.lang.Long |
getValue()
The currently set value, null if no value has been set.
|
RoleManagerUpdatable |
givePermissions(java.util.Collection<Permission> permissions)
Adds the specified permissions to the result value
If any of the specified permissions is present in the revoked permissions it will be removed! This does not apply immediately - it is applied in the value returned by getValue() |
RoleManagerUpdatable |
givePermissions(Permission... permissions)
Adds the specified permissions to the result value
If any of the specified permissions is present in the revoked permissions it will be removed! This does not apply immediately - it is applied in the value returned by getValue() |
RoleManagerUpdatable |
reset()
|
RoleManagerUpdatable |
revokePermissions(java.util.Collection<Permission> permissions)
Adds the specified permissions to the result value
These will override permissions that are given through givePermissions(Collection) and givePermissions(Permission...) !
This does not apply immediately - it is applied in the value returned by getValue() |
RoleManagerUpdatable |
revokePermissions(Permission... permissions)
Adds the specified permissions to the result value
These will override permissions that are given through givePermissions(Collection) and givePermissions(Permission...) !
This does not apply immediately - it is applied in the value returned by getValue() |
RoleManagerUpdatable |
setPermissions(java.util.Collection<Permission> permissions)
Sets the permissions for this PermissionField.
|
RoleManagerUpdatable |
setPermissions(Permission... permissions)
Sets the permissions for this PermissionField.
|
RoleManagerUpdatable |
setValue(java.lang.Long value)
Sets the value which should be used in the update
operation for the Manager instance.
|
equals, getManager, getOriginalValue, isSet, shouldUpdate, toString
public PermissionField(RoleManagerUpdatable manager, java.util.function.Supplier<java.lang.Long> originalValue)
public RoleManagerUpdatable setValue(java.lang.Long value)
Field.isSet()
to return true
!setValue
in class Field<java.lang.Long,RoleManagerUpdatable>
value
- The value that should be used by the update operationjava.lang.IllegalArgumentException
- If the provided value is nullField.isSet()
public RoleManagerUpdatable setPermissions(Permission... permissions)
permissions
- The Permissions
to useRoleManagerUpdatable
instance
for this PermissionField for chaining conveniencejava.lang.IllegalArgumentException
- If the provided permission collection or any of the permissions within
it are nullInsufficientPermissionException
- If the permissions provided require other permissions
to be availablepublic RoleManagerUpdatable setPermissions(java.util.Collection<Permission> permissions)
permissions
- The Permissions
to useRoleManagerUpdatable
instance
for this PermissionField for chaining conveniencejava.lang.IllegalArgumentException
- If the provided permission collection or any of the permissions within
it are nullInsufficientPermissionException
- If the permissions provided require other permissions
to be availablepublic void checkValue(java.lang.Long value)
Field
This method is abstract and requires specific implementation
checkValue
in class Field<java.lang.Long,RoleManagerUpdatable>
value
- The value that should be checkedpublic RoleManagerUpdatable givePermissions(Permission... permissions)
getValue()
permissions
- Permissions that should be grantedRoleManagerUpdatable
instance
for this PermissionField for chaining conveniencejava.lang.IllegalArgumentException
- If any of the provided Permissions is null
public RoleManagerUpdatable givePermissions(java.util.Collection<Permission> permissions)
getValue()
permissions
- Permissions that should be grantedRoleManagerUpdatable
instance
for this PermissionField for chaining conveniencejava.lang.IllegalArgumentException
- If any of the provided Permissions is null
public RoleManagerUpdatable revokePermissions(Permission... permissions)
givePermissions(Collection)
and givePermissions(Permission...)
!
getValue()
permissions
- Permissions that should be revokedRoleManagerUpdatable
instance
for this PermissionField for chaining conveniencejava.lang.IllegalArgumentException
- If any of the provided Permissions is null
public RoleManagerUpdatable revokePermissions(java.util.Collection<Permission> permissions)
givePermissions(Collection)
and givePermissions(Permission...)
!
getValue()
permissions
- Permissions that should be revokedRoleManagerUpdatable
instance
for this PermissionField for chaining conveniencejava.lang.IllegalArgumentException
- If any of the provided Permissions is null
public java.lang.Long getValue()
Field
getValue
in class Field<java.lang.Long,RoleManagerUpdatable>
Field.getOriginalValue()
public RoleManagerUpdatable reset()
Field
reset
in class Field<java.lang.Long,RoleManagerUpdatable>
Field.setValue(Object)
public java.util.List<Permission> getPermissions()
Permissions
that are calculated from getValue()
using Permission.getPermissions(long)
getOriginalPermissions()
public java.util.List<Permission> getOriginalPermissions()
Permissions
that have been calculated Field.getOriginalValue()
using Permission.getPermissions(long)
getPermissions()