Class Role

  • All Implemented Interfaces:
    Comparable

    public final class Role
    extends Object
    implements Comparable
    Class representing a role, which holds a set of Permissions.
    Author:
    Thomas Maurel
    • Constructor Detail

      • Role

        @DataBoundConstructor
        public Role​(@NonNull
                    String name,
                    @CheckForNull
                    String pattern,
                    @CheckForNull
                    Set<String> permissionIds,
                    @CheckForNull
                    String description,
                    String templateName)
      • Role

        public Role​(@NonNull
                    String name,
                    @CheckForNull
                    String pattern,
                    @CheckForNull
                    Set<String> permissionIds,
                    @CheckForNull
                    String description)
      • Role

        public Role​(String name,
                    Pattern pattern,
                    Set<Permission> permissions,
                    @CheckForNull
                    String description)
        Create a Role.
        Parameters:
        name - The role name
        pattern - The pattern matching AccessControlled objects names
        permissions - The Permissions associated to the role. null permissions will be ignored.
        description - A description for the role
      • Role

        public Role​(String name,
                    Pattern pattern,
                    Set<Permission> permissions,
                    @CheckForNull
                    String description,
                    String templateName)
        Create a Role.
        Parameters:
        name - The role name
        pattern - The pattern matching AccessControlled objects names
        permissions - The Permissions associated to the role. null permissions will be ignored.
        description - A description for the role
        templateName - True to mark this role as generated
    • Method Detail

      • setTemplateName

        public void setTemplateName​(@CheckForNull
                                    String templateName)
      • getTemplateName

        public String getTemplateName()
      • getName

        public String getName()
        Getter for the role name.
        Returns:
        The role name
      • getPattern

        public Pattern getPattern()
        Getter for the regexp pattern.
        Returns:
        The pattern associated to the role
      • refreshPermissionsFromTemplate

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public void refreshPermissionsFromTemplate​(@CheckForNull
                                                   PermissionTemplate permissionTemplate)
        Updates the permissions from the given template. The name of the given template must match the configured template name in the role.
        Parameters:
        permissionTemplate - PermissionTemplate
      • getDescription

        @CheckForNull
        public String getDescription()
        Gets the role description.
        Returns:
        Role description. null if not set
      • hasPermission

        public Boolean hasPermission​(Permission permission)
        Checks if the role holds the given Permission.
        Parameters:
        permission - The permission you want to check
        Returns:
        True if the role holds this permission
      • compareTo

        public int compareTo​(@NonNull
                             Object o)
        Compare role names. Used to sort the sets. We presume that any role name is being used once and only once.
        Specified by:
        compareTo in interface Comparable
        Parameters:
        o - The object you want to compare this instance to
        Returns:
        Comparison of role names
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object