Interface PermissionCollection

  • All Known Implementing Classes:
    DefaultPermissionCollection

    public interface PermissionCollection
    Interface representing a collection of Permission objects.

    With a PermissionCollection, you can:

    • add a permission to the collection using the add method.
    • check to see if a particular permission is implied in the collection, using the implies method.
    • enumerate all the permissions, using the elements method.
    See Also:
    Permission
    • Method Detail

      • add

        PermissionCollection add​(Permission... permissions)
        Adds a permission object to the current collection of permission objects.
        Parameters:
        permissions - the Permission objects to add.
      • remove

        PermissionCollection remove​(Permission... permissions)
        Removes a permission object from the current collection of permission objects.
        Parameters:
        permissions - the Permission objects to remove.
      • get

        Permission get​(String name)
        Gets a permission object matching the specified name.
        Parameters:
        name - The fully qualified name of the permission.
        Returns:
        A Permission instance or null if not found.
      • collection

        Collection<Permission> collection()
        Returns all the Permission objects in the collection.
        Returns:
        A collection of all the Permissions.
      • implies

        boolean implies​(Permission permission)
        Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.
        Parameters:
        permission - the Permission object to compare.
        Returns:
        true if "permission" is implied by the permissions in the collection, false if not.
      • impliesName

        boolean impliesName​(Permission permission)
        It returns true provided this collection already contains a permission which implies by name (See Permission.impliesName(Permission)) the permission passed as a parameter.
        Parameters:
        permission - the permission to check
        Returns:
        true if the permission name is implied by this collection, false otherwise.
      • merge

        PermissionCollection merge​(PermissionCollection other,
                                   int priority)
        Get all the permissions from this collection and the given one and puts them into a brand new collection instance. Any "redundant" permission instance ("implied" by other permissions in the collection) are left out from the outcome. Notice also, the priority parameter is taken into account in case the same permission is present in both collections.
        Parameters:
        other - the collection to merge.
        priority - integer indicating what to do if the same permission is found in both collections:
        • 0 = same priority (GRANTED permissions win by default)
        • negative integer = this collection wins
        • positive integer = the other collection wins
        Returns:
        A collection containing the merge result.
      • clone

        PermissionCollection clone()
        Creates an exact copy of this instance.
        Returns:
        A brand new Permission instance