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

org.vertexium.cypher.ast.model.CypherStringMatch Maven / Gradle / Ivy

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

import org.vertexium.VertexiumException;

import java.util.stream.Stream;

public class CypherStringMatch extends CypherAstBase {
    private final CypherAstBase valueExpression;
    private final CypherAstBase stringExpression;
    private final Op op;

    public CypherStringMatch(CypherAstBase valueExpression, CypherAstBase stringExpression, Op op) {
        this.valueExpression = valueExpression;
        this.stringExpression = stringExpression;
        this.op = op;
    }

    public CypherAstBase getValueExpression() {
        return valueExpression;
    }

    public CypherAstBase getStringExpression() {
        return stringExpression;
    }

    public Op getOp() {
        return op;
    }

    @Override
    public String toString() {
        switch (getOp()) {
            case STARTS_WITH:
                return String.format("%s STARTS WITH %s", getValueExpression(), getStringExpression());
            case ENDS_WITH:
                return String.format("%s ENDS WITH %s", getValueExpression(), getStringExpression());
            case CONTAINS:
                return String.format("%s CONTAINS %s", getValueExpression(), getStringExpression());
            default:
                throw new VertexiumException("unhandled: " + getOp());
        }
    }

    public enum Op {
        STARTS_WITH,
        ENDS_WITH,
        CONTAINS
    }

    @Override
    public Stream getChildren() {
        return Stream.of(valueExpression, stringExpression);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy