class KiePMMLSegmentFactory {

    public static Map<String, String> getSegmentSourcesMap(
            final String parentPackageName,
            final DataDictionary dataDictionary,
            final TransformationDictionary transformationDictionary,
            final Segment segment,
            final KnowledgeBuilder kBuilder,
            final List<KiePMMLModel> nestedModels) {
        logger.debug(GET_SEGMENT, segment);
        final String packageName = getSanitizedPackageName(parentPackageName + "." + segment.getId());
        final KiePMMLModel nestedModel = getFromCommonDataAndTransformationDictionaryAndModelFromPlugin(
                packageName,
                dataDictionary,
                transformationDictionary,
                segment.getModel(),
                kBuilder)
                .orElseThrow(() -> new KiePMMLException("Failed to get the KiePMMLModel for segment " + segment.getModel().getModelName()));
        if (!(nestedModel instanceof HasSourcesMap)) {
            throw new KiePMMLException("Retrieved KiePMMLModel for segment " + segment.getModel().getModelName() + " " +
                                               "does not implement HasSources");
        }
        nestedModels.add(nestedModel);
        return getSegmentSourcesMap(packageName, dataDictionary, segment);
    }

    private  KiePMMLSegmentFactory();

}