Search in sources :

Example 1 with CompiledAccExpression

use of org.mule.mvel2.compiler.CompiledAccExpression in project mule by mulesoft.

the class AbstractVariableEnricherDataTypePropagator method doPropagate.

@Override
protected boolean doPropagate(PrivilegedEvent event, PrivilegedEvent.Builder builder, TypedValue typedValue, ASTNode node) {
    if (isAssignmentNode(node)) {
        CompiledAccExpression compiledAccExpression = getCompiledAccExpression(node);
        if (compiledAccExpression.getAccessor() instanceof VariableAccessor) {
            VariableAccessor variableAccessor = (VariableAccessor) compiledAccExpression.getAccessor();
            if (variableAccessor.getProperty().equals(propertyName)) {
                final AccessorNode nextNode = variableAccessor.getNextNode();
                if (nextNode.getNextNode() == null) {
                    String propertyName = null;
                    if (nextNode instanceof MapAccessorNest) {
                        final MapAccessorNest mapAccesorNest = (MapAccessorNest) nextNode;
                        if (mapAccesorNest.getProperty().isLiteralOnly()) {
                            propertyName = (String) ((ExecutableLiteral) mapAccesorNest.getProperty()).getLiteral();
                        }
                    } else if (nextNode instanceof MapAccessor) {
                        propertyName = (String) ((MapAccessor) nextNode).getProperty();
                    }
                    if (propertyName != null && containsVariable(event, propertyName)) {
                        propertyName = getUnescapedPropertyName(propertyName);
                        addVariable(event, builder, typedValue, propertyName);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : AccessorNode(org.mule.mvel2.compiler.AccessorNode) VariableAccessor(org.mule.mvel2.optimizers.impl.refl.nodes.VariableAccessor) ExecutableLiteral(org.mule.mvel2.compiler.ExecutableLiteral) CompiledAccExpression(org.mule.mvel2.compiler.CompiledAccExpression) MapAccessor(org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor) MapAccessorNest(org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessorNest)

Aggregations

AccessorNode (org.mule.mvel2.compiler.AccessorNode)1 CompiledAccExpression (org.mule.mvel2.compiler.CompiledAccExpression)1 ExecutableLiteral (org.mule.mvel2.compiler.ExecutableLiteral)1 MapAccessor (org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor)1 MapAccessorNest (org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessorNest)1 VariableAccessor (org.mule.mvel2.optimizers.impl.refl.nodes.VariableAccessor)1