class SecurityAnalysisTool implements Tool {

    static SecurityAnalysisInput buildPreprocessedInput(SecurityAnalysisExecutionInput executionInput,
                                                        Supplier<LimitViolationFilter> filterInitializer,
                                                        SecurityAnalysisPreprocessorFactory preprocessorFactory) {

        SecurityAnalysisInput input = new SecurityAnalysisInput(executionInput.getNetworkVariant())
                .setParameters(executionInput.getParameters())
                .setFilter(filterInitializer.get());

        executionInput.getResultExtensions().stream()
                .map(SecurityAnalysisInterceptors::createInterceptor)
                .forEach(input::addInterceptor);

        if (!executionInput.getViolationTypes().isEmpty()) {
            input.getFilter().setViolationTypes(ImmutableSet.copyOf(executionInput.getViolationTypes()));
        }

        executionInput.getContingenciesSource()
                .map(preprocessorFactory::newPreprocessor)
                .ifPresent(p -> p.preprocess(input));

        return input;
    }

}