org.babyfish.jimmer.sql.ast.impl.ConcatExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
The newest version!
package org.babyfish.jimmer.sql.ast.impl;
import org.babyfish.jimmer.sql.ast.Expression;
import org.babyfish.jimmer.sql.ast.impl.render.AbstractSqlBuilder;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Objects;
class ConcatExpression
extends AbstractExpression
implements StringExpressionImplementor {
private Expression first;
private List> others;
ConcatExpression(Expression first, List> others) {
this.first = first;
this.others = others;
}
@Override
public void accept(@NotNull AstVisitor visitor) {
((Ast) first).accept(visitor);
for (Expression> other : others) {
((Ast) other).accept(visitor);
}
}
@Override
public void renderTo(@NotNull AbstractSqlBuilder> builder) {
builder.sql("concat(");
renderChild((Ast) first, builder);
for (Expression> other : others) {
builder.sql(", ");
renderChild((Ast) other, builder);
}
builder.sql(")");
}
@Override
protected boolean determineHasVirtualPredicate() {
return hasVirtualPredicate(first) || hasVirtualPredicate(others);
}
@Override
protected Ast onResolveVirtualPredicate(AstContext ctx) {
this.first = ctx.resolveVirtualPredicate(first);
this.others = ctx.resolveVirtualPredicates(others);
return this;
}
@Override
public int precedence() {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConcatExpression that = (ConcatExpression) o;
return first.equals(that.first) && others.equals(that.others);
}
@Override
public int hashCode() {
return Objects.hash(first, others);
}
}