org.pitest.mutationtest.build.CompoundInterceptorFactory Maven / Gradle / Ivy
package org.pitest.mutationtest.build;
import org.pitest.classinfo.ClassByteArraySource;
import org.pitest.coverage.CoverageDatabase;
import org.pitest.mutationtest.config.ReportOptions;
import org.pitest.plugin.FeatureSelector;
import org.pitest.plugin.FeatureSetting;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
public class CompoundInterceptorFactory {
private final FeatureSelector features;
public CompoundInterceptorFactory(List features,
Collection filters) {
this.features = new FeatureSelector<>(features, filters);
}
public CompoundMutationInterceptor createInterceptor(
ReportOptions data,
CoverageDatabase coverage,
ClassByteArraySource source) {
final List interceptors = this.features.getActiveFeatures().stream()
.map(toInterceptor(this.features, data, coverage, source))
.collect(Collectors.toList());
return new CompoundMutationInterceptor(interceptors);
}
private static Function toInterceptor(
FeatureSelector features,
ReportOptions data,
CoverageDatabase coverage,
ClassByteArraySource source) {
return a -> a.createInterceptor(new InterceptorParameters(features.getSettingForFeature(a.provides().name()), data, coverage, source));
}
}