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

org.vertexium.cypher.ast.model.CypherSetItem 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 abstract class CypherSetItem extends CypherAstBase {
    private final TLeft left;
    private final Op op;
    private final TRight right;

    public CypherSetItem(TLeft left, Op op, TRight right) {
        this.left = left;
        this.op = op;
        this.right = right;
    }

    public TLeft getLeft() {
        return left;
    }

    public Op getOp() {
        return op;
    }

    public TRight getRight() {
        return right;
    }

    @Override
    public String toString() {
        // should be a list of label names
        if (getRight() instanceof CypherListLiteral) {
            return String.format("%s%s", getLeft(), getRight());
        }
        return String.format(
            "%s %s %s",
            getLeft(),
            getOp(),
            getRight()
        );
    }

    public enum Op {
        PLUS_EQUAL,
        EQUAL;

        public String toString() {
            switch (this) {
                case PLUS_EQUAL:
                    return "+=";
                case EQUAL:
                    return "=";
                default:
                    throw new VertexiumException("unhandled op: " + this);
            }
        }
    }

    @Override
    public Stream getChildren() {
        return Stream.of(getLeft(), getRight());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy