blob: 55c3d5803e14822b3361df8ffc5834c1fff812cb [file] [log] [blame]
package org.eclipse.papyrus.robotics.library.matcher;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
import org.eclipse.papyrus.designer.languages.common.base.ElementUtils;
import org.eclipse.papyrus.robotics.library.advice.AbstractActionPatternAdvice;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.TemplateBinding;
public class ActionCommPatternMatcher implements IElementMatcher {
@Override
public boolean matches(EObject eObject) {
if (eObject instanceof Class) {
Class clazz = (Class) eObject;
if (clazz.eResource() != null) {
NamedElement eventCommPatternNE = ElementUtils.getQualifiedElementFromRS(clazz, AbstractActionPatternAdvice.ACTION_PATTERN);
for (TemplateBinding binding : clazz.getTemplateBindings()) {
if (binding.getTargets().contains(eventCommPatternNE)) {
return true;
}
}
}
}
return false;
}
}