use of org.kie.pmml.models.tree.model.KiePMMLScoreDistribution in project drools by kiegroup.
the class KiePMMLNodeFactory method populateEvaluateNodeWithScoreDistributions.
/**
* Set the <b>scoreDistribution</b> <code>VariableDeclarator</code> initializer of the given <code>BlockStmt</code>.
* If <b>scoreDistributionsParam</b> is <code>null</code>, a <code>NullLiteralExpr</code> is set.
* <p>
* <code>List<KiePMMLScoreDistribution> scoreDistributions = null;</code>
* </p>
* Otherwise
* <p>
* <code>List<KiePMMLScoreDistribution> scoreDistributions = arrays.asList(new KiePMMLScoreDistribution(....));</code>
* </p>
*
* @param toPopulate
* @param scoreDistributionsParam
*/
static void populateEvaluateNodeWithScoreDistributions(final BlockStmt toPopulate, final List<ScoreDistribution> scoreDistributionsParam) {
final Expression scoreDistributionsExpression;
if (scoreDistributionsParam == null) {
scoreDistributionsExpression = new NullLiteralExpr();
} else {
int counter = 0;
final NodeList<Expression> scoreDistributionsArguments = new NodeList<>();
for (ScoreDistribution scoreDistribution : scoreDistributionsParam) {
String nestedVariableName = String.format("scoreDistribution_%s", counter);
scoreDistributionsArguments.add(getKiePMMLScoreDistribution(nestedVariableName, scoreDistribution));
counter++;
}
scoreDistributionsExpression = new MethodCallExpr();
((MethodCallExpr) scoreDistributionsExpression).setScope(new NameExpr(Arrays.class.getSimpleName()));
((MethodCallExpr) scoreDistributionsExpression).setName("asList");
((MethodCallExpr) scoreDistributionsExpression).setArguments(scoreDistributionsArguments);
}
CommonCodegenUtils.setVariableDeclaratorValue(toPopulate, SCORE_DISTRIBUTIONS, scoreDistributionsExpression);
}
Aggregations