class KiePMMLScorecardModelCharacteristicASTFactory {

    protected KiePMMLReasonCodeAndValue getKiePMMLReasonCodeAndValue(final Attribute attribute,
                                                                     final String characteristicReasonCode,
                                                                     final Number characteristicBaselineScore) {
        if (!useReasonCodes) {
            return null;
        }
        if (characteristicBaselineScore == null && baselineScore == null) {
            throw new KiePMMLException("Missing default and characteristic defined baselineScore needed for useReasonCodes == true");
        }
        if (reasonCodeAlgorithm == null) {
            throw new KiePMMLException("Missing reasonCodeAlgorithm needed for useReasonCodes == true");
        }
        String reasonCode = attribute.getReasonCode() != null && !(attribute.getReasonCode().isEmpty()) ? attribute.getReasonCode() : characteristicReasonCode;
        if (reasonCode == null || reasonCode.isEmpty()) {
            throw new KiePMMLException("Missing reasonCode needed for useReasonCodes == true");
        }
        double baseLineScoreToUse = characteristicBaselineScore != null ? characteristicBaselineScore.doubleValue() : baselineScore.doubleValue();
        double partialScoreToUse = attribute.getPartialScore() != null ? attribute.getPartialScore().doubleValue() : 0.0;
        if (REASONCODE_ALGORITHM.POINTS_BELOW.equals(reasonCodeAlgorithm)) {
            baseLineScoreToUse = baseLineScoreToUse - partialScoreToUse;
        } else {
            baseLineScoreToUse = partialScoreToUse - baseLineScoreToUse;
        }
        return new KiePMMLReasonCodeAndValue(reasonCode, baseLineScoreToUse);
    }

    private  KiePMMLScorecardModelCharacteristicASTFactory(final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap, final List<KiePMMLOutputField> outputFields, final DATA_TYPE targetType);

}