blob: 97de5025ac9dcc5557c46fb552640790adc2e0af [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.SendCommPatternAdvice;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.TemplateBinding;
public class SendCommPatternMatcher implements IElementMatcher {
@Override
public boolean matches(EObject eObject) {
if (eObject instanceof Class) {
Class clazz = (Class) eObject;
if (clazz.eResource() != null) {
NamedElement sendCommPatternNE = ElementUtils.getQualifiedElementFromRS(clazz, SendCommPatternAdvice.SEND_PATTERN);
for (TemplateBinding binding : clazz.getTemplateBindings()) {
if (binding.getTargets().contains(sendCommPatternNE)) {
return true;
}
}
}
}
return false;
}
}