use of org.drools.modelcompiler.builder.generator.DslMethodNames.GET_CHANNEL_CALL in project drools by kiegroup.
the class Consequence method rewriteChannels.
private void rewriteChannels(BlockStmt consequence) {
consequence.findAll(MethodCallExpr.class).stream().map(MethodCallExpr::getScope).filter(Optional::isPresent).map(Optional::get).filter(sc -> sc instanceof ArrayAccessExpr).map(aae -> (ArrayAccessExpr) aae).filter(aae -> aae.getName().asNameExpr().getNameAsString().equals("channels")).forEach(aae -> {
String channelName = aae.getIndex().asStringLiteralExpr().asString();
MethodCallExpr mce = new MethodCallExpr(new NameExpr("drools"), GET_CHANNEL_CALL);
mce.addArgument("\"" + channelName + "\"");
aae.replace(mce);
});
}
Aggregations