Search in sources :

Example 1 with ReactiveTransformer

use of com.dexels.navajo.reactive.api.ReactiveTransformer in project navajo by Dexels.

the class ASTPipeDefinition method transformerElements.

@SuppressWarnings("unchecked")
private List<Object> transformerElements(List<String> problems, String originalExpression, Function<String, FunctionClassification> functionClassifier, Function<String, Optional<Node>> mapResolver) {
    int count = jjtGetNumChildren();
    List<Object> pipeElements = new ArrayList<>();
    for (int i = (partial ? 0 : 1); i < count; i++) {
        ContextExpression interpretToLambda = jjtGetChild(i).interpretToLambda(problems, originalExpression, functionClassifier, mapResolver);
        Object result = interpretToLambda.apply().value;
        if (result instanceof Function) {
            Function<StreamScriptContext, Function<DataItem, DataItem>> merger = (Function<StreamScriptContext, Function<DataItem, DataItem>>) result;
            pipeElements.add(merger);
        } else if (result instanceof ReactiveTransformer) {
            ReactiveTransformer transformer = (ReactiveTransformer) result;
            pipeElements.add(transformer);
        } else {
            logger.warn("huh? {}", result);
        // something weird
        }
    }
    return pipeElements;
}
Also used : Function(java.util.function.Function) ReactiveTransformer(com.dexels.navajo.reactive.api.ReactiveTransformer) DataItem(com.dexels.navajo.document.stream.DataItem) ContextExpression(com.dexels.navajo.expression.api.ContextExpression) ArrayList(java.util.ArrayList) StreamScriptContext(com.dexels.navajo.document.stream.api.StreamScriptContext)

Aggregations

DataItem (com.dexels.navajo.document.stream.DataItem)1 StreamScriptContext (com.dexels.navajo.document.stream.api.StreamScriptContext)1 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)1 ReactiveTransformer (com.dexels.navajo.reactive.api.ReactiveTransformer)1 ArrayList (java.util.ArrayList)1 Function (java.util.function.Function)1