1 package com.stateofflow.eclipse.metrics.builder;
2
3 import org.eclipse.core.runtime.CoreException;
4 import org.eclipse.jdt.core.ICompilationUnit;
5
6 import com.stateofflow.eclipse.metrics.configuration.MetricsConfiguration;
7 import com.stateofflow.eclipse.metrics.location.MetricLocation;
8 import com.stateofflow.eclipse.metrics.metric.MetricId;
9 import com.stateofflow.eclipse.metrics.util.ProgressMonitor;
10
11 public class EnabledCalculatorMetricProcessorDecorator implements MetricProcessor {
12 private final MetricProcessor underlying;
13 private final MetricsConfiguration configuration;
14
15 public EnabledCalculatorMetricProcessorDecorator(final MetricsConfiguration configuration, final MetricProcessor underlying) {
16 this.configuration = configuration;
17 this.underlying = underlying;
18 }
19
20 public void afterMeasuringAllCompilationUnits(final ProgressMonitor newChild) throws CoreException {
21 underlying.afterMeasuringAllCompilationUnits(newChild);
22 }
23
24 public boolean hasPostProcessingPhase() {
25 return underlying.hasPostProcessingPhase();
26 }
27
28 public void preCompilationUnit(final ICompilationUnit compilationUnit) throws CoreException {
29 underlying.preCompilationUnit(compilationUnit);
30 }
31
32 public void noteMethodValue(final MetricId metricId, final MetricLocation location, final int value) {
33 if (configuration.isEnabled(metricId)) {
34 underlying.noteMethodValue(metricId, location, value);
35 }
36 }
37
38 public void noteTypeValue(final MetricId metricId, final MetricLocation location, final int value) {
39 if (configuration.isEnabled(metricId)) {
40 underlying.noteTypeValue(metricId, location, value);
41 }
42 }
43
44 }
45