Class AbstractNamedPermission<This extends AbstractNamedPermission<This>>

  • All Implemented Interfaces:
    Serializable, Guard, PermissionVerifier
    Direct Known Subclasses:
    AbstractActionPermission, AbstractNameOnlyPermission

    public abstract class AbstractNamedPermission<This extends AbstractNamedPermission<This>>
    extends AbstractPermission<This>
    An abstract base class for named permissions with useful API and implementation methods.

    Subclasses of this class are always serialized as a special serialized permission object, which captures the type class, the permission name (if any), and the permission action (if any) as a string. Therefore, none of the fields of any subclass of this class are serialized unless they are included in the name or actions properties.

    Concrete subclasses are expected to be immutable and final.

    Author:
    David M. Lloyd
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractNamedPermission

        protected AbstractNamedPermission​(String name)
        Construct a new instance.
        Parameters:
        name - the permission name (must not be null)
    • Method Detail

      • withName

        public abstract This withName​(String name)
        Create a new permission which is identical to this one, except with a new name.
        Parameters:
        name - the name to use (must not be null)
        Returns:
        the new permission
      • nameEquals

        public boolean nameEquals​(String name)
        Determine whether this permission has a name equal to the given name.
        Parameters:
        name - the name to check
        Returns:
        true if this permission's name is equal to the given name, false otherwise
      • nameEquals

        public final boolean nameEquals​(Permission permission)
        Determine whether this permission has a name equal to the name of the given permission. If the given permission is of a different type than this permission, false is returned.
        Parameters:
        permission - the permission whose name is to be checked
        Returns:
        true if this permission's name is equal to the given permission's name, false otherwise
      • nameEquals

        public final boolean nameEquals​(This permission)
        Determine whether this permission has a name equal to the name of the given permission.
        Parameters:
        permission - the permission whose name is to be checked
        Returns:
        true if this permission's name is equal to the given permission's name, false otherwise
      • nameHashCode

        protected int nameHashCode()
        Get the hash code of the name. The default implementation returns getName().hashCode().
        Returns:
        the hash code of the name
      • impliesName

        public boolean impliesName​(String name)
        Determine whether this permission implies the given name.
        Parameters:
        name - the name to check
        Returns:
        true if this permission's name implies the given name, false otherwise
      • impliesName

        public final boolean impliesName​(Permission permission)
        Determine whether this permission implies the name of the given permission. If the permission is not of the same type as this permission, false is returned.
        Parameters:
        permission - the permission whose name is to be checked
        Returns:
        true if this permission's name implies the given name, false otherwise
      • impliesName

        public boolean impliesName​(This permission)
        Determine whether this permission implies the name of the given permission.
        Parameters:
        permission - the permission whose name is to be checked
        Returns:
        true if this permission's name implies the given name, false otherwise
      • equals

        public boolean equals​(This other)
        Description copied from class: AbstractPermission
        Determine whether this permission object is equal to another object of this permission type.
        Specified by:
        equals in class AbstractPermission<This extends AbstractNamedPermission<This>>
        Parameters:
        other - the permission to compare to
        Returns:
        true if the object is a permission equal to this one; false otherwise