How to retrieve list of all stereotypes i defined for a specific type of elements inside a project?


#1

Hi guys,
Is it possible to retrieve a list of all stereotypes that i defined for a specific type of elements inside a project ?
for example all stereotypes of Usecases in a project.


#2

You may get all stereotypes and check its .baseType == UseCase

like this:

String lSpecifiedModelType = IModelElementFactory.MODEL_TYPE_USE_CASE;

Collection<IStereotype> lSpecifiedStereotypes = new ArrayList<IStereotype>();

IProject lProject = ApplicationManager.instance().getProjectManager().getProject();
IModelElement[] lStereotypes = lProject.toAllLevelModelElementArray(IModelElementFactory.MODEL_TYPE_STEREOTYPE);
if (lStereotypes != null) {
	for (IModelElement lStereotype : lStereotypes) {
		if (lSpecifiedModelType.equals(((IStereotype) lStereotype).getBaseType())) {
			lSpecifiedStereotypes.add((IStereotype) lStereotype);
		}
	}
}

return lSpecifiedStereotypes;

#3

thank you :pray: