All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.cypher.executionPlan.LiteralExecutionStep Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.cypher.executionPlan;

import org.vertexium.cypher.SingleRowVertexiumCypherResult;
import org.vertexium.cypher.VertexiumCypherQueryContext;
import org.vertexium.cypher.VertexiumCypherResult;
import org.vertexium.cypher.ast.model.CypherLiteral;

public class LiteralExecutionStep extends DefaultExecutionStep implements ExecutionStepWithResultName {
    private final String resultName;
    private final Object value;

    public LiteralExecutionStep(String resultName, Object value) {
        this.resultName = resultName;
        this.value = value;
    }

    public Object getValue() {
        return value;
    }

    @Override
    public VertexiumCypherResult execute(VertexiumCypherQueryContext ctx, VertexiumCypherResult source) {
        if (source == null) {
            source = new SingleRowVertexiumCypherResult();
        }
        return source.peek(row -> row.pushScope(resultName, CypherLiteral.toJava(value)));
    }

    @Override
    public String toString() {
        return String.format("%s {resultName='%s', value=%s}", super.toString(), resultName, value);
    }

    @Override
    public String getResultName() {
        return resultName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy