Search in sources :

Example 1 with VariableAssignmentExpression

use of org.apache.atlas.groovy.VariableAssignmentExpression in project incubator-atlas by apache.

the class OptimizationContext method addFunctionDefinition.

public String addFunctionDefinition(VariableDeclaration decl, GroovyExpression body) {
    String functionName = getUniqueFunctionName();
    List<VariableDeclaration> decls = (decl == null) ? Collections.<VariableDeclaration>emptyList() : Collections.singletonList(decl);
    ClosureExpression bodyClosure = new ClosureExpression(body, decls);
    VariableAssignmentExpression expr = new VariableAssignmentExpression(functionName, bodyClosure);
    initialStatements.add(expr);
    functionBodies.put(functionName, bodyClosure);
    return functionName;
}
Also used : VariableDeclaration(org.apache.atlas.groovy.ClosureExpression.VariableDeclaration) ClosureExpression(org.apache.atlas.groovy.ClosureExpression) VariableAssignmentExpression(org.apache.atlas.groovy.VariableAssignmentExpression)

Example 2 with VariableAssignmentExpression

use of org.apache.atlas.groovy.VariableAssignmentExpression in project incubator-atlas by apache.

the class OptimizationContext method getDefineResultVariableStmt.

public GroovyExpression getDefineResultVariableStmt() {
    GroovyExpression castExpression = new TypeCoersionExpression(new ListExpression(), "Set");
    GroovyExpression resultVarDef = new VariableAssignmentExpression(RESULT_VARIABLE, castExpression);
    return resultVarDef;
}
Also used : TypeCoersionExpression(org.apache.atlas.groovy.TypeCoersionExpression) ListExpression(org.apache.atlas.groovy.ListExpression) GroovyExpression(org.apache.atlas.groovy.GroovyExpression) VariableAssignmentExpression(org.apache.atlas.groovy.VariableAssignmentExpression)

Aggregations

VariableAssignmentExpression (org.apache.atlas.groovy.VariableAssignmentExpression)2 ClosureExpression (org.apache.atlas.groovy.ClosureExpression)1 VariableDeclaration (org.apache.atlas.groovy.ClosureExpression.VariableDeclaration)1 GroovyExpression (org.apache.atlas.groovy.GroovyExpression)1 ListExpression (org.apache.atlas.groovy.ListExpression)1 TypeCoersionExpression (org.apache.atlas.groovy.TypeCoersionExpression)1