Community
Participate
Working Groups
Here is an utility API proposal (specific to static profiles) that could be shared in order get StereotypeApplication instances easily. Usage example (assuming "Requirement" is a Stereotype from a Static Profile) : Requirement req = Utils.getStereotypeApplication(umlElement, Requirement.class); /** * Convenient method to retrieve the StereotypeApplication by passing an element of the static profile. * * @param <T> * the type of stereotype to look for * @param element * an UML model element * @param clazz * the class of an element of a static profile. Compatible sub-types will be returned as well * @return the stereotype application or null if such stereotype is not applied */ @SuppressWarnings("unchecked") public static <T extends EObject> T getStereotypeApplication(Element element, java.lang.Class<T> clazz) { for(EObject stereoApplication : element.getStereotypeApplications()) { // check whether the stereotype is an instance of the passed parameter class if(clazz.isInstance(stereoApplication)) { return (T)stereoApplication; } } return null; }
The utility method has been added and committed to git.