Search in sources :

Example 1 with FunctionCall

use of org.springframework.data.cassandra.core.query.Columns.FunctionCall in project spring-data-cassandra by spring-projects.

the class QueryMapper method getMappedSelector.

private Selector getMappedSelector(Selector selector, CqlIdentifier cqlIdentifier) {
    if (selector instanceof ColumnSelector) {
        ColumnSelector columnSelector = (ColumnSelector) selector;
        ColumnSelector mappedColumnSelector = ColumnSelector.from(cqlIdentifier);
        return columnSelector.getAlias().map(mappedColumnSelector::as).orElse(mappedColumnSelector);
    }
    if (selector instanceof FunctionCall) {
        FunctionCall functionCall = (FunctionCall) selector;
        FunctionCall mappedFunctionCall = FunctionCall.from(functionCall.getExpression(), functionCall.getParameters().stream().map(obj -> {
            if (obj instanceof Selector) {
                return getMappedSelector((Selector) obj, cqlIdentifier);
            }
            return obj;
        }).toArray());
        return // 
        functionCall.getAlias().map(// 
        mappedFunctionCall::as).orElse(mappedFunctionCall);
    }
    throw new IllegalArgumentException(String.format("Selector [%s] not supported", selector));
}
Also used : ColumnSelector(org.springframework.data.cassandra.core.query.Columns.ColumnSelector) FunctionCall(org.springframework.data.cassandra.core.query.Columns.FunctionCall) ColumnSelector(org.springframework.data.cassandra.core.query.Columns.ColumnSelector) Selector(org.springframework.data.cassandra.core.query.Columns.Selector)

Aggregations

ColumnSelector (org.springframework.data.cassandra.core.query.Columns.ColumnSelector)1 FunctionCall (org.springframework.data.cassandra.core.query.Columns.FunctionCall)1 Selector (org.springframework.data.cassandra.core.query.Columns.Selector)1