Search in sources :

Example 1 with MethodReference

use of org.springframework.expression.spel.ast.MethodReference in project spring-framework by spring-projects.

the class InternalSpelExpressionParser method maybeEatMethodOrProperty.

// This is complicated due to the support for dollars in identifiers.
// Dollars are normally separate tokens but there we want to combine
// a series of identifiers and dollars into a single identifier.
private boolean maybeEatMethodOrProperty(boolean nullSafeNavigation) {
    if (peekToken(TokenKind.IDENTIFIER)) {
        Token methodOrPropertyName = nextToken();
        SpelNodeImpl[] args = maybeEatMethodArgs();
        if (args == null) {
            // property
            push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.data, toPos(methodOrPropertyName)));
            return true;
        }
        // method reference
        push(new MethodReference(nullSafeNavigation, methodOrPropertyName.data, toPos(methodOrPropertyName), args));
        // TODO what is the end position for a method reference? the name or the last arg?
        return true;
    }
    return false;
}
Also used : SpelNodeImpl(org.springframework.expression.spel.ast.SpelNodeImpl) MethodReference(org.springframework.expression.spel.ast.MethodReference) PropertyOrFieldReference(org.springframework.expression.spel.ast.PropertyOrFieldReference)

Aggregations

MethodReference (org.springframework.expression.spel.ast.MethodReference)1 PropertyOrFieldReference (org.springframework.expression.spel.ast.PropertyOrFieldReference)1 SpelNodeImpl (org.springframework.expression.spel.ast.SpelNodeImpl)1