net.sf.nakeduml.emf.extraction.ConstraintExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metamodel Show documentation
Show all versions of metamodel Show documentation
A uml code generator and execution engine
The newest version!
package net.sf.nakeduml.emf.extraction;
import net.sf.nakeduml.feature.StepDependency;
import net.sf.nakeduml.feature.visit.VisitAfter;
import net.sf.nakeduml.metamodel.core.INakedClassifier;
import net.sf.nakeduml.metamodel.core.internal.NakedConstraintImpl;
import nl.klasse.octopus.model.OclUsageType;
import org.eclipse.emf.common.util.EList;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Element;
@StepDependency(phase = EmfExtractionPhase.class,requires = InstanceExtractor.class,after = InstanceExtractor.class)
public class ConstraintExtractor extends AbstractExtractorFromEmf{
@VisitAfter(matchSubclasses=true)
public void initializeClassifier(Classifier emfClassifier){
INakedClassifier classifier=(INakedClassifier) getNakedPeer(emfClassifier);
EList ownedRules = emfClassifier.getOwnedRules();
for(Constraint c :ownedRules){
NakedConstraintImpl nc = new NakedConstraintImpl();
initialize(nc, c, emfClassifier);
nc.setSpecification(getValueSpecification(classifier, c.getSpecification(), OclUsageType.INV));
if(c.getConstrainedElements().size() == 1){
Element constrained = c.getConstrainedElements().get(0);
nc.setConstrainedElement(getNakedPeer(constrained));
}
}
}
}