org.babyfish.jimmer.sql.ast.impl.OptimisticLockNewValueExpression 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.meta.ImmutableProp;
import org.babyfish.jimmer.meta.TypedProp;
import org.babyfish.jimmer.sql.ast.impl.render.AbstractSqlBuilder;
import org.babyfish.jimmer.sql.ast.impl.render.BatchSqlBuilder;
import org.jetbrains.annotations.NotNull;
class OptimisticLockNewValueExpression
extends AbstractExpression {
private final ImmutableProp prop;
OptimisticLockNewValueExpression(TypedProp.Scalar, V> prop) {
this.prop = prop.unwrap();
}
@Override
protected boolean determineHasVirtualPredicate() {
return false;
}
@Override
protected Ast onResolveVirtualPredicate(AstContext ctx) {
return this;
}
@Override
public void accept(@NotNull AstVisitor visitor) {
}
@Override
public void renderTo(@NotNull AbstractSqlBuilder> builder) {
if (!(builder instanceof BatchSqlBuilder)) {
throw new IllegalStateException(
"The \"" +
OptimisticLockNewValueExpression.class.getName() +
"\" does not accept simple sql builder"
);
}
((BatchSqlBuilder)builder).value(prop);
}
@SuppressWarnings("unchecked")
@Override
public Class getType() {
return (Class) prop.getReturnClass();
}
@Override
public int precedence() {
return 0;
}
static class Str extends OptimisticLockNewValueExpression implements StringExpressionImplementor {
Str(TypedProp.Scalar, String> prop) {
super(prop);
}
}
static class Num> extends OptimisticLockNewValueExpression implements NumericExpressionImplementor {
Num(TypedProp.Scalar, N> prop) {
super(prop);
}
}
static class Cmp> extends OptimisticLockNewValueExpression implements ComparableExpressionImplementor {
Cmp(TypedProp.Scalar, V> prop) {
super(prop);
}
}
}