All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pitest.mutationtest.CompoundMutationResultInterceptor Maven / Gradle / Ivy

There is a newer version: 1.17.1
Show newest version
package org.pitest.mutationtest;

import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class CompoundMutationResultInterceptor implements MutationResultInterceptor {

    private final List interceptors;

    public CompoundMutationResultInterceptor(List interceptors) {
        this.interceptors = interceptors.stream()
                .sorted(Comparator.comparing(MutationResultInterceptor::priority))
                .collect(Collectors.toList());
    }

    public CompoundMutationResultInterceptor add(MutationResultInterceptor extra) {
        interceptors.add(0, extra);
        return this;
    }

    @Override
    public Collection modify(Collection in) {
        Collection result = in;
        for (MutationResultInterceptor each : interceptors) {
            result = each.modify(result);
        }
        return result;
    }

    @Override
    public Collection remaining() {
        return interceptors.stream()
                .flatMap(i -> i.remaining().stream())
                .collect(Collectors.toList());
    }

    @Override
    public String description() {
        return "Composite interceptor";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy