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

org.babyfish.jimmer.sql.ast.impl.OptimisticLockNewValueExpression Maven / Gradle / Ivy

There is a newer version: 0.9.19
Show newest version
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 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 prop) {
            super(prop);
        }
    }

    static class Num> extends OptimisticLockNewValueExpression implements NumericExpressionImplementor {

        Num(TypedProp.Scalar prop) {
            super(prop);
        }
    }

    static class Cmp> extends OptimisticLockNewValueExpression implements ComparableExpressionImplementor {

        Cmp(TypedProp.Scalar prop) {
            super(prop);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy