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

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

The 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(ImmutableProp prop) {
        this.prop = prop;
    }

    @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(ImmutableProp prop) {
            super(prop);
        }
    }

    static class Num> extends OptimisticLockNewValueExpression implements NumericExpressionImplementor {

        Num(ImmutableProp prop) {
            super(prop);
        }
    }

    static class Cmp> extends OptimisticLockNewValueExpression implements ComparableExpressionImplementor {

        Cmp(ImmutableProp prop) {
            super(prop);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy