blob: 68b1b366eca9371b4b5e4fe075a25b3138847666 [file] [log] [blame]
tarendt55062d62012-10-01 18:17:32 +00001<%@ jet package="org.eclipse.emf.refactor.metrics" class="CompositeCalculateClassTemplate"
2imports="org.eclipse.emf.refactor.metrics.generator.core.CompositeMetricInfo"%>
tarendt940b7b82012-09-26 16:55:28 +00003<%CompositeMetricInfo info = (CompositeMetricInfo) argument; %>
4package <%=info.getPackage()%>;
5
tarendt940b7b82012-09-26 16:55:28 +00006import java.util.List;
7import org.eclipse.emf.ecore.EObject;
tarendt55062d62012-10-01 18:17:32 +00008import org.eclipse.emf.refactor.metrics.interfaces.IMetricCalculator;
9import org.eclipse.emf.refactor.metrics.interfaces.IOperation;
10import org.eclipse.emf.refactor.metrics.core.Metric;
11import org.eclipse.emf.refactor.metrics.operations.Operations;
tarendt940b7b82012-09-26 16:55:28 +000012
tarendt55062d62012-10-01 18:17:32 +000013public final class <%=info.getClassName()%> implements IMetricCalculator {
tarendt940b7b82012-09-26 16:55:28 +000014
15 private List<EObject> context;
16 private String metricID1 = "<%=info.getFirstMetric().getId()%>";
17 private String metricID2 = "<%=info.getSecondMetric().getId()%>";
18
19 IOperation operation = Operations.getOperation("<%=info.getOperationName()%>");
20
21 @Override
22 public void setContext(List<EObject> context) {
23 this.context = context;
24 }
25
26 @Override
27 public double calculate() {
28 Metric metric1 = Metric.getMetricInstanceFromId(metricID1);
29 Metric metric2 = Metric.getMetricInstanceFromId(metricID2);
30
tarendt55062d62012-10-01 18:17:32 +000031 IMetricCalculator calc1 = metric1.getCalculateClass();
32 IMetricCalculator calc2 = metric2.getCalculateClass();
tarendt940b7b82012-09-26 16:55:28 +000033
34 calc1.setContext(this.context);
35 calc2.setContext(this.context);
36 return operation.calculate(calc1.calculate(),calc2.calculate());
37 }
38
39}