Search in sources :

Example 1 with TypeReference

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

the class InternalSpelExpressionParser method maybeEatTypeReference.

private boolean maybeEatTypeReference() {
    if (peekToken(TokenKind.IDENTIFIER)) {
        Token typeName = peekToken();
        if (!"T".equals(typeName.stringValue())) {
            return false;
        }
        // It looks like a type reference but is T being used as a map key?
        Token t = nextToken();
        if (peekToken(TokenKind.RSQUARE)) {
            // looks like 'T]' (T is map key)
            push(new PropertyOrFieldReference(false, t.data, toPos(t)));
            return true;
        }
        eatToken(TokenKind.LPAREN);
        SpelNodeImpl node = eatPossiblyQualifiedId();
        // dotted qualified id
        // Are there array dimensions?
        int dims = 0;
        while (peekToken(TokenKind.LSQUARE, true)) {
            eatToken(TokenKind.RSQUARE);
            dims++;
        }
        eatToken(TokenKind.RPAREN);
        this.constructedNodes.push(new TypeReference(toPos(typeName), node, dims));
        return true;
    }
    return false;
}
Also used : SpelNodeImpl(org.springframework.expression.spel.ast.SpelNodeImpl) PropertyOrFieldReference(org.springframework.expression.spel.ast.PropertyOrFieldReference) TypeReference(org.springframework.expression.spel.ast.TypeReference)

Aggregations

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