| package org.eclipse.papyrus.pdp4eng.req.profile.constraints; |
| |
| import java.util.Iterator; |
| |
| import org.eclipse.uml2.uml.Element; |
| import org.eclipse.uml2.uml.Stereotype; |
| |
| public class GDPRRequiementHelper { |
| |
| public static boolean isGDPR_Requirement(Element element) { |
| |
| for (Iterator<Stereotype> iterator = element.getAppliedStereotypes().iterator(); iterator.hasNext();) { |
| Stereotype type = (Stereotype) iterator.next(); |
| if(isGDPRRequirementStereotype(type)) { |
| return true; |
| } |
| |
| } |
| return false; |
| } |
| |
| /** |
| * test if the stereotype is a SysML Requirement Stereotype |
| * @param stereotype a given stereotype |
| * @return return true if this is a SysML stereotype or inherits directly or indirectly from requirement |
| */ |
| public static boolean isGDPRRequirementStereotype(Stereotype stereotype) { |
| if( "GDPRPrinciple".equals(stereotype.getName())){ |
| return true; |
| } |
| for(org.eclipse.uml2.uml.Class superStereotype : stereotype.getSuperClasses()) { |
| if( superStereotype instanceof Stereotype){ |
| if(isGDPRRequirementStereotype((Stereotype)superStereotype)){ |
| return true; |
| } |
| } |
| } |
| return false; |
| } |
| } |