Interface Permissible

All Superinterfaces:
Comparable<Permissible>, DocPropertyHolder, eu.cloudnetservice.common.Named
All Known Implementing Classes:
AbstractPermissible, PermissionGroup, PermissionUser

public interface Permissible extends eu.cloudnetservice.common.Named, DocPropertyHolder, Comparable<Permissible>
The permissible represents the base for any permission holding object. The permissible is mutable, but any changes to the permissible itself do not have any effect without updating the permissible using the permission management.
Since:
4.0
  • Method Details

    • potency

      int potency()
      Gets the potency of this permissible. The potency is used for comparison of permissibles. A higher potency results in higher significance.
      Returns:
      the potency of this permissible.
      See Also:
    • removePermission

      boolean removePermission(@NonNull @NonNull String permission)
      Removes the given permission from this permissible. This only removes global permissions, not group specific ones.

      After removing the permission an update is required.

      Parameters:
      permission - the permission to remove.
      Returns:
      true if any permission was removed, false otherwise.
      Throws:
      NullPointerException - if the given permission is null.
    • removePermission

      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.

      Parameters:
      permission - the permission to remove.
      group - the target group to remove the permission from.
      Returns:
      true if any permission was removed, false otherwise.
      Throws:
      NullPointerException - if the given group or permission is null.
    • permissions

      Gets all global permissions of this permissible. Specific group permissions are not included.
      Returns:
      all global permissions.
    • groupPermissions

      @NonNull @NonNull Map<String,Set<Permission>> groupPermissions()
      Gets all group specific permissions. Global permissions are not included.
      Returns:
      all group specific permissions.
    • groupNames

      Collects all group names of this permissible.
      Returns:
      all groups names.
    • permission

      Gets a permission of this permissible by its name.
      Parameters:
      name - the name of the permission.
      Returns:
      the permission with the given name or null if the name is null or no permission was found.
    • isPermissionSet

      default boolean isPermissionSet(@NonNull @NonNull String name)
      Checks if the permission has the given permission.
      Parameters:
      name - the case-insensitive name of the permission.
      Returns:
      true if the permissible has the given permission, false otherwise.
      Throws:
      NullPointerException - if the given name is null.
    • creationTime

      long creationTime()
      Gets the creation time as unix timestamp of this permissible.
      Returns:
      the creation time of this permissible.
    • addPermission

      void addPermission(@NonNull @NonNull Permission permission)
      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.

      Parameters:
      permission - the permission to add.
      Throws:
      NullPointerException - if the given permission is null.
    • addPermission

      default void addPermission(@NonNull @NonNull String permission)
      Adds the given permission with a potency of 0 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.

      Parameters:
      permission - the permission to add.
      Throws:
      NullPointerException - if the given permission is null.
    • addPermission

      void addPermission(@NonNull @NonNull String group, @NonNull @NonNull Permission permission)
      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.

      Parameters:
      group - the group to add the permission for.
      permission - the permission to add.
      Throws:
      NullPointerException - if the given group or permission is null.
    • addPermission

      default void addPermission(@NonNull @NonNull String group, @NonNull @NonNull String permission)
      Adds the given permission to this permissible for the specified target group, the potency is set to 0. 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.

      Parameters:
      group - the group to add the permission for.
      permission - the permission to add.
      Throws:
      NullPointerException - if the given group or permission is null.
    • permissionNames

      @NonNull default @Unmodifiable @NonNull Collection<String> permissionNames()
      Gets an unmodifiable collection of all global permission names.
      Returns:
      all global permissions
    • hasPermission

      Checks if the collection of given permissions contains a permission that matches the given permission.
      Parameters:
      permissions - the permissions to search in.
      permission - the permission to check for.
      Returns:
      the result of the permission search.
      Throws:
      NullPointerException - if the given permissions or permission is null.
    • findMatchingPermission

      @Nullable default @Nullable Permission findMatchingPermission(@NonNull @NonNull Collection<Permission> permissions, @NonNull @NonNull Permission permission)
      Finds the best matching permission in the given permissions by logically checking the absolute potency against each other to find the permission with the highest positive or negative potency.
      Parameters:
      permissions - the permission to check for.
      permission - the initial permission to check against.
      Returns:
      the logic permission which has the highest potency, null if none matches.
      Throws:
      NullPointerException - if the given permissions or permission is null.
      See Also:
    • hasPermission

      Checks if this permissible has the given permission for the specified target group. Only group permissions are included in this check, global permissions don't have any effect.
      Parameters:
      group - the target group of the permission.
      permission - the permission to check for.
      Returns:
      the result of the permission check.
      Throws:
      NullPointerException - if the given group or permission is null.
    • hasPermission

      @NonNull default @NonNull PermissionCheckResult hasPermission(@NonNull @NonNull Permission permission)
      Checks if this permissible has the given permission. Only global permissions are included in this check.
      Parameters:
      permission - the permission to check for.
      Returns:
      the result of the permission check.
      Throws:
      NullPointerException - if the given permission is null.
    • hasPermission

      @NonNull default @NonNull PermissionCheckResult hasPermission(@NonNull @NonNull String permission)
      Checks if this permissible has the given permission with a potency of 0. Only global permissions are included in this check.
      Parameters:
      permission - the permission to check for.
      Returns:
      the result of the permission check.
      Throws:
      NullPointerException - if the given permission is null.
    • compareTo

      default int compareTo(@NonNull @NonNull Permissible o)
      Specified by:
      compareTo in interface Comparable<Permissible>