Product SiteDocumentation Site

⁠3.4.2. Relationship Stereotypes

Relationship Stereotypes represent those recurring concepts applied to a specific Relationship type. Let's take for an example the Grant relationship type provided by the Basic Model:
​@RelationshipStereotype(GRANT)
​public class Grant extends AbstractAttributedType implements Relationship {
​}
Considering that the Grant type represents the relationship between others identity types (eg.: users and groups) and roles, we need to annotate the class with the @RelationshipStereotype(GRANT) annotation.
This annotations supports the following stereotypes:
  • GRANT - Should be used by relationship types that represent an association between any identity type and a role type.
  • GROUP_MEMBERSHIP - Should be used by relationship types that represent an association between an identity type and a group type. Usually, the associated identity type is an user that is member of a group.
Each stereotype has its own common set of properties. Those properties represent some specific information which is usually associated with a stereotype. For example, grant stereotypes usually have a assignee and a role property.
Stereotype properties are defined using the StereotypeProperty annotation. It provides a set of values defining the properties for a specific stereotype.
​@RelationshipStereotype(GRANT)
​public class Grant extends AbstractAttributedType implements Relationship {
​
​    @InheritsPrivileges("role")
​    @StereotypeProperty(RELATIONSHIP_GRANT_ASSIGNEE)
​    public IdentityType getAssignee() {
​        return this.assignee;
​    }
​
​    @StereotypeProperty(RELATIONSHIP_GRANT_ROLE)
​    public Role getRole() {
​        return this.role;
​    }
​
​}
The code example above defines that the assignee property of the Role type is related with the assignee of a grant relationship stereotype. The same with the role property, which is related with the role assigned to an assignee.