use of com.github.javaparser.ast.expr.MethodReferenceExpr in project drools by kiegroup.
the class Expressions method genContextType.
public static Expression genContextType(Map<String, Expression> fields) {
final ClassOrInterfaceType sie = parseClassOrInterfaceType(java.util.AbstractMap.SimpleImmutableEntry.class.getCanonicalName());
sie.setTypeArguments(parseClassOrInterfaceType(String.class.getCanonicalName()), parseClassOrInterfaceType(org.kie.dmn.feel.lang.Type.class.getCanonicalName()));
List<Expression> entryParams = fields.entrySet().stream().map(e -> new ObjectCreationExpr(null, sie, new NodeList<>(stringLiteral(e.getKey()), e.getValue()))).collect(Collectors.toList());
MethodCallExpr mOf = new MethodCallExpr(new NameExpr(java.util.stream.Stream.class.getCanonicalName()), "of");
entryParams.forEach(mOf::addArgument);
MethodCallExpr mCollect = new MethodCallExpr(mOf, "collect");
mCollect.addArgument(new MethodCallExpr(new NameExpr(java.util.stream.Collectors.class.getCanonicalName()), "toMap").addArgument(new MethodReferenceExpr(new NameExpr(java.util.Map.Entry.class.getCanonicalName()), new NodeList<>(), "getKey")).addArgument(new MethodReferenceExpr(new NameExpr(java.util.Map.Entry.class.getCanonicalName()), new NodeList<>(), "getValue")));
return new ObjectCreationExpr(null, MapBackedTypeT, new NodeList<>(stringLiteral("[anonymous]"), mCollect));
}
use of com.github.javaparser.ast.expr.MethodReferenceExpr in project drools by kiegroup.
the class KiePMMLNodeFactory method getEvaluateNodeMethodReference.
/**
* Return a <b>evaluateNode</b> <code>MethodReferenceExpr</code>
* <p>
* <code>{_fullNodeClassName_}::evaluateNode</code>
* </p>
*
* @param fullNodeClassName
* @return
*/
static MethodReferenceExpr getEvaluateNodeMethodReference(final String fullNodeClassName) {
MethodReferenceExpr toAdd = new MethodReferenceExpr();
toAdd.setScope(new NameExpr(fullNodeClassName));
toAdd.setIdentifier(EVALUATE_NODE);
return toAdd;
}
use of com.github.javaparser.ast.expr.MethodReferenceExpr in project drools by kiegroup.
the class KiePMMLNodeFactoryTest method getEvaluateNodeMethodReference.
@Test
public void getEvaluateNodeMethodReference() {
String fullNodeClassName = "full.node.NodeClassName";
MethodReferenceExpr retrieved = KiePMMLNodeFactory.getEvaluateNodeMethodReference(fullNodeClassName);
assertEquals(fullNodeClassName, retrieved.getScope().toString());
assertEquals(EVALUATE_NODE, retrieved.getIdentifier());
}
use of com.github.javaparser.ast.expr.MethodReferenceExpr in project checker-framework by typetools.
the class DoubleJavaParserVisitor method visit.
@Override
public void visit(final MethodReferenceExpr node1, final Node other) {
MethodReferenceExpr node2 = (MethodReferenceExpr) other;
defaultAction(node1, node2);
node1.getScope().accept(this, node2.getScope());
node1.getTypeArguments().ifPresent(l -> visitLists(l, node2.getTypeArguments().get()));
}
use of com.github.javaparser.ast.expr.MethodReferenceExpr in project drools by kiegroup.
the class AccumulateInline method addAccumulateClassInitializationToMethod.
private void addAccumulateClassInitializationToMethod(MethodCallExpr accumulateDSL, String identifier) {
this.packageModel.addGeneratedPOJO(accumulateInlineClass);
final MethodCallExpr functionDSL = createDslTopLevelMethod(ACC_FUNCTION_CALL);
functionDSL.addArgument(new MethodReferenceExpr(new NameExpr(accumulateInlineClassName), new NodeList<>(), "new"));
functionDSL.addArgument(context.getVarExpr(identifier));
final String bindingId = this.basePattern.getIdentifier();
final MethodCallExpr asDSL = new MethodCallExpr(functionDSL, BIND_AS_CALL);
asDSL.addArgument(context.getVarExpr(bindingId));
accumulateDSL.addArgument(asDSL);
}
Aggregations