org.babyfish.jimmer.sql.ast.impl.SubQueryFunctionExpression 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
package org.babyfish.jimmer.sql.ast.impl;
import org.babyfish.jimmer.sql.ast.impl.render.AbstractSqlBuilder;
import org.babyfish.jimmer.sql.ast.query.TypedSubQuery;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public abstract class SubQueryFunctionExpression extends AbstractExpression {
private TypedSubQuery subQuery;
SubQueryFunctionExpression(TypedSubQuery subQuery) {
this.subQuery = subQuery;
}
protected abstract String functionName();
@SuppressWarnings("unchecked")
@Override
public Class getType() {
return (Class) ((ExpressionImplementor>) subQuery).getType();
}
@Override
public int precedence() {
return 0;
}
@Override
public void accept(@NotNull AstVisitor visitor) {
((Ast) subQuery).accept(visitor);
}
@Override
public void renderTo(@NotNull AbstractSqlBuilder> builder) {
builder.sql(functionName());
renderChild((Ast) subQuery, builder);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SubQueryFunctionExpression> that = (SubQueryFunctionExpression>) o;
return subQuery.equals(that.subQuery);
}
@Override
protected boolean determineHasVirtualPredicate() {
return hasVirtualPredicate(subQuery);
}
@Override
protected Ast onResolveVirtualPredicate(AstContext ctx) {
return (Ast) ctx.resolveVirtualPredicate(subQuery);
}
@Override
public int hashCode() {
return Objects.hash(subQuery);
}
public static class All extends SubQueryFunctionExpression {
public All(TypedSubQuery subQuery) {
super(subQuery);
}
@Override
protected String functionName() {
return "all";
}
}
public static class Any extends SubQueryFunctionExpression {
public Any(TypedSubQuery subQuery) {
super(subQuery);
}
@Override
protected String functionName() {
return "any";
}
}
}