Interface Role
-
- All Known Subinterfaces:
Role.Flat
- All Known Implementing Classes:
Role.OfName
public interface RoleRepresents a role. Role can imply other roles, support for that is provided by the classRole.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); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRole.Flatstatic classRole.Hierarchy<R extends Role>static classRole.OfName
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanimplies(Role role)java.lang.Stringname()static Role.OfNameofName(java.lang.String name)
-
-
-
Method Detail
-
name
java.lang.String name()
-
implies
boolean implies(Role role)
-
ofName
static Role.OfName ofName(java.lang.String name)
-
-