1 | package de.uka.ipd.sdq.dsexplore.opt4j.operator; |
2 | |
3 | import org.eclipse.emf.ecore.util.EcoreUtil; |
4 | import org.opt4j.operator.copy.Copy; |
5 | |
6 | import de.uka.ipd.sdq.dsexplore.opt4j.genotype.DesignDecisionGenotype; |
7 | import de.uka.ipd.sdq.pcm.designdecision.Choice; |
8 | |
9 | public class CopyDesignDecisionGenotype implements Copy<DesignDecisionGenotype> { |
10 | |
11 | @Override |
12 | public DesignDecisionGenotype copy(DesignDecisionGenotype genotype) { |
13 | DesignDecisionGenotype copy = genotype.newInstance(); |
14 | |
15 | for (Choice choice : genotype) { |
16 | //only copies the object and contained other model elements |
17 | //(i.e. the full tree that is made out of containment references). |
18 | //As the PCm model elements are never in a containment relation here, |
19 | //the PCM will not be tampered with here. |
20 | Choice copiedChoice = (Choice)EcoreUtil.copy(choice); |
21 | copy.add(copiedChoice); |
22 | } |
23 | return copy; |
24 | } |
25 | |
26 | } |