class KiePMMLScorecardModel extends KiePMMLDroolsModel {

    protected void populateWithOutputFields(PMML4Result toPopulate) {
        if (outputFields != null) {
            final Map<String, Double> sortedByValue
                    = outputFieldsMap.entrySet()
                    .stream()
                    .filter(entry -> entry.getValue() instanceof Double && (Double) entry.getValue() > 0) // TODO: check removal of negative values
                    .map((Function<Map.Entry<String, Object>, Map.Entry<String, Double>>) entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), (Double) entry.getValue()))
                    .sorted(Map.Entry.<String, Double>comparingByValue().reversed())
                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
            final List<String> orderedReasonCodes = new ArrayList<>(sortedByValue.keySet());
            for (KiePMMLOutputField outputField : outputFields) {
                switch (outputField.getResultFeature()) {
                    case REASON_CODE:
                        if (outputField.getRank() != null) {
                            int index = outputField.getRank() - 1;
                            String resultCode = null;
                            String resultVariableName = outputField.getName();
                            if (index < orderedReasonCodes.size()) {
                                resultCode = orderedReasonCodes.get(index);
                            }
                            toPopulate.updateResultVariable(resultVariableName, resultCode);
                        }
                        break;
                    default:
                        // not managed, yet
                }
            }
        }
    }

    protected  KiePMMLScorecardModel(String modelName, List<KiePMMLExtension> extensions);

}