All Known Subinterfaces:
Role.Flat
All Known Implementing Classes:
Role.OfName

public interface Role
Represents a role. Role can imply other roles, support for that is provided by the class Role.Hierarchy.

The recommended way to define roles is using enums, the interface is designed for that. An example:

 enum ExampleRoles implements Role {
   GUEST,
   FOO(GUEST),
   BAR(GUEST),
   ADMIN(FOO, BAR);

   private final Hierarchy<ExampleRoles> hierarchy;

   ExampleRoles(ExampleRoles... parents) {
     hierarchy = new Hierarchy<>(this, r -> r.hierarchy, parents);
   }

   @Override
   public boolean implies(Role that) {
     return hierarchy.implies(that);
   }
 }