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

org.babyfish.jimmer.sql.ast.Predicate Maven / Gradle / Ivy

There is a newer version: 0.8.180
Show newest version
package org.babyfish.jimmer.sql.ast;

import org.babyfish.jimmer.lang.NewChain;
import org.babyfish.jimmer.sql.ast.impl.CompositePredicate;
import org.babyfish.jimmer.sql.ast.impl.SqlExpressionContext;
import org.babyfish.jimmer.sql.ast.impl.SqlExpressions;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Objects;
import java.util.function.Consumer;

public interface Predicate extends Expression {

    /**
     * This function will be deleted in 1.0.0,
     * please use the static method {@link #and(Predicate...)}
     */
    @Deprecated
    @NewChain
    Predicate and(@Nullable Predicate other);

    /**
     * This function will be deleted in 1.0.0,
     * please use the static method {@link #or(Predicate...)}
     */
    @Deprecated
    @NewChain
    Predicate or(@Nullable Predicate other);

    /**
     * This function will be deleted in 1.0.0,
     * please use the static method {@link #not(Predicate)}
     */
    @Deprecated
    @NewChain
    Predicate not();

    @Nullable
    static Predicate and(Predicate ... predicates) {
        return CompositePredicate.and(predicates);
    }

    @Nullable
    static Predicate or(Predicate ... predicates) {
        return CompositePredicate.or(predicates);
    }
    
    @Nullable
    static Predicate not(@Nullable Predicate predicate) {
        if (predicate == null) {
            return null;
        }
        return predicate.not();
    }

    static Predicate sql(String sql) {
        return SqlExpressions.of(Boolean.class, sql, null);
    }

    static Predicate sql(String sql, Expression expression, Object ... values) {
        return SqlExpressions.of(Boolean.class, sql, new Expression[] { expression }, values);
    }

    static Predicate sql(String sql, Expression[] expressions, Object ... values) {
        return SqlExpressions.of(Boolean.class, sql, expressions, values);
    }

    static Predicate sql(String sql, Consumer block) {
        return SqlExpressions.of(Boolean.class, sql, block);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy