Class AbstractPermissible
java.lang.Object
eu.cloudnetservice.driver.permission.AbstractPermissible
- All Implemented Interfaces:
eu.cloudnetservice.common.document.property.DefaultedDocPropertyHolder<eu.cloudnetservice.common.document.gson.JsonDocument,,Permissible> eu.cloudnetservice.common.document.property.DocPropertyHolder<eu.cloudnetservice.common.document.gson.JsonDocument,,Permissible> eu.cloudnetservice.common.Nameable,Permissible,Comparable<Permissible>
- Direct Known Subclasses:
PermissionGroup,PermissionUser
public abstract class AbstractPermissible
extends Object
implements eu.cloudnetservice.common.document.property.DefaultedDocPropertyHolder<eu.cloudnetservice.common.document.gson.JsonDocument,Permissible>, Permissible
An abstract implementation of a permissible for shared usage.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final longprotected final Map<String,Set<Permission>> protected final Stringprotected final Set<Permission>protected final intprotected final eu.cloudnetservice.common.document.gson.JsonDocument -
Constructor Summary
ConstructorsConstructorDescriptionAbstractPermissible(@NonNull String name, int potency, long createdTime, @NonNull Set<Permission> permissions, @NonNull Map<String, Set<Permission>> groupPermissions, @NonNull eu.cloudnetservice.common.document.gson.JsonDocument properties) Constructs a new abstract permissible instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPermission(@NonNull Permission permission) Adds the given permission to this permissible.voidaddPermission(@NonNull String group, @NonNull Permission permission) Adds the given permission to this permissible for the specified target group.private voidaddPermission(@NonNull Set<Permission> permissions, @NonNull Permission permission) Adds the given permission into the set of permissions.longGets the creation time as unix timestamp of this permissible.Gets all group specific permissions.name()Gets all global permissions of this permissible.intpotency()Gets the potency of this permissible.@NonNull eu.cloudnetservice.common.document.gson.JsonDocumentbooleanremovePermission(@NonNull String permission) Removes the given permission from this permissible.booleanremovePermission(@NonNull String permission, @NonNull String group) Removes the given permission from this permissible and the given target group.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.common.document.property.DefaultedDocPropertyHolder
propertyAbsent, propertyPresent, readProperty, readPropertyOrDefault, readPropertyOrGet, readPropertyOrThrow, readPropertyOrThrow, removeProperty, writeProperty, writePropertyIfAbsent, writePropertyIfAbsent, writePropertyIfPresent, writePropertyIfPresentMethods inherited from interface eu.cloudnetservice.driver.permission.Permissible
addPermission, addPermission, compareTo, findMatchingPermission, groupNames, hasPermission, hasPermission, hasPermission, hasPermission, isPermissionSet, permission, permissionNames
-
Field Details
-
name
-
potency
protected final int potency -
createdTime
protected final long createdTime -
permissions
-
groupPermissions
-
properties
protected final eu.cloudnetservice.common.document.gson.JsonDocument properties
-
-
Constructor Details
-
AbstractPermissible
public AbstractPermissible(@NonNull @NonNull String name, int potency, long createdTime, @NonNull @NonNull Set<Permission> permissions, @NonNull @NonNull Map<String, Set<Permission>> groupPermissions, @NonNull @NonNull eu.cloudnetservice.common.document.gson.JsonDocument properties) Constructs a new abstract permissible instance.- Parameters:
name- the name of the permissible.potency- the potency of the permissible.createdTime- the creation time as unix timestamp.permissions- all permissions of the permissible.groupPermissions- all permissions of the permissible that are per (service) group.properties- extra properties for the permissible.- Throws:
NullPointerException- if the given name, permissions, groupPermissions or properties is null.
-
-
Method Details
-
addPermission
private void addPermission(@NonNull @NonNull Set<Permission> permissions, @NonNull @NonNull Permission permission) Adds the given permission into the set of permissions. If the collection contains a permission with the same name it is removed before adding the new permission.- Parameters:
permissions- the set of permissions to add the given permission to.permission- the permission to add to the other permissions.- Throws:
NullPointerException- if the given permissions or the permission is null.
-
addPermission
Adds the given permission to this permissible. If a permission with the same name already exists the permission is replaced with the given one.After adding the permission an update is required.
- Specified by:
addPermissionin interfacePermissible- Parameters:
permission- the permission to add.
-
addPermission
Adds the given permission to this permissible for the specified target group. If a permission with the same name already exists the permission is replaced with the given one.After adding the permission an update is required.
- Specified by:
addPermissionin interfacePermissible- Parameters:
group- the group to add the permission for.permission- the permission to add.
-
removePermission
Removes the given permission from this permissible. This only removes global permissions, not group specific ones.After removing the permission an update is required.
- Specified by:
removePermissionin interfacePermissible- Parameters:
permission- the permission to remove.- Returns:
- true if any permission was removed, false otherwise.
-
removePermission
public boolean removePermission(@NonNull @NonNull String permission, @NonNull @NonNull String group) Removes the given permission from this permissible and the given target group. This only removes group specific permissions, not global ones.After removing the permission an update is required.
- Specified by:
removePermissionin interfacePermissible- Parameters:
permission- the permission to remove.group- the target group to remove the permission from.- Returns:
- true if any permission was removed, false otherwise.
-
creationTime
public long creationTime()Gets the creation time as unix timestamp of this permissible.- Specified by:
creationTimein interfacePermissible- Returns:
- the creation time of this permissible.
-
name
- Specified by:
namein interfaceeu.cloudnetservice.common.Nameable
-
potency
public int potency()Gets the potency of this permissible. The potency is used for comparison of permissibles. A higher potency results in higher significance.- Specified by:
potencyin interfacePermissible- Returns:
- the potency of this permissible.
- See Also:
-
permissions
Gets all global permissions of this permissible. Specific group permissions are not included.- Specified by:
permissionsin interfacePermissible- Returns:
- all global permissions.
-
groupPermissions
Gets all group specific permissions. Global permissions are not included.- Specified by:
groupPermissionsin interfacePermissible- Returns:
- all group specific permissions.
-
propertyHolder
- Specified by:
propertyHolderin interfaceeu.cloudnetservice.common.document.property.DocPropertyHolder<eu.cloudnetservice.common.document.gson.JsonDocument,Permissible>
-