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

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

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

import java.util.stream.Stream;

public class CypherWithClause extends CypherClause {
    private final boolean distinct;
    private final CypherReturnBody returnBody;
    private final CypherAstBase where;

    public CypherWithClause(boolean distinct, CypherReturnBody returnBody, CypherAstBase where) {
        this.distinct = distinct;
        this.returnBody = returnBody;
        this.where = where;
    }

    public boolean isDistinct() {
        return distinct;
    }

    public CypherReturnBody getReturnBody() {
        return returnBody;
    }

    public CypherAstBase getWhere() {
        return where;
    }

    @Override
    public String toString() {
        return String.format(
            "WITH %s%s%s",
            isDistinct() ? "DISTINCT " : "",
            getReturnBody().toString(),
            getWhere() == null ? "" : " WHERE " + getWhere().toString()
        );
    }

    @Override
    public Stream getChildren() {
        return Stream.of(returnBody, where);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy