class KiePMMLSegmentFactory {

    public static KiePMMLSegment getSegment(final DataDictionary dataDictionary,
                                            final TransformationDictionary transformationDictionary,
                                            final Segment segment,
                                            final KnowledgeBuilder kBuilder) {
        logger.debug(GET_SEGMENT, segment);
        return KiePMMLSegment.builder(segment.getId(),
                                      getKiePMMLExtensions(segment.getExtensions()),
                                      getPredicate(segment.getPredicate(), dataDictionary),
                                      getFromCommonDataAndTransformationDictionaryAndModel(dataDictionary,
                                                                                           transformationDictionary,
                                                                                           segment.getModel(),
                                                                                           kBuilder).orElseThrow(() -> new KiePMMLException("Failed to get the KiePMMLModel for segment " + segment.getModel().getModelName())))
                .withWeight(segment.getWeight().doubleValue())
                .build();
    }

    private  KiePMMLSegmentFactory();

}