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

io.micronaut.data.model.jpa.criteria.impl.AbstractCriteriaBuilder Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2017-2021 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.data.model.jpa.criteria.impl;

import io.micronaut.core.annotation.Internal;
import io.micronaut.core.annotation.NextMajorVersion;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.data.model.jpa.criteria.PersistentEntityCriteriaBuilder;
import io.micronaut.data.model.jpa.criteria.impl.expression.BinaryExpression;
import io.micronaut.data.model.jpa.criteria.impl.expression.BinaryExpressionType;
import io.micronaut.data.model.jpa.criteria.impl.expression.FunctionExpression;
import io.micronaut.data.model.jpa.criteria.impl.expression.LiteralExpression;
import io.micronaut.data.model.jpa.criteria.impl.expression.SubqueryExpression;
import io.micronaut.data.model.jpa.criteria.impl.predicate.ConjunctionPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.DisjunctionPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.ExistsSubqueryPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.LikePredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.NegatedPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.BetweenPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.BinaryPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.InPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.UnaryPredicate;
import io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateBinaryOp;
import io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateUnaryOp;
import io.micronaut.data.model.jpa.criteria.impl.expression.UnaryExpression;
import io.micronaut.data.model.jpa.criteria.impl.expression.UnaryExpressionType;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CollectionJoin;
import jakarta.persistence.criteria.CompoundSelection;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Join;
import jakarta.persistence.criteria.ListJoin;
import jakarta.persistence.criteria.MapJoin;
import jakarta.persistence.criteria.Order;
import jakarta.persistence.criteria.ParameterExpression;
import jakarta.persistence.criteria.Path;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.Selection;
import jakarta.persistence.criteria.SetJoin;
import jakarta.persistence.criteria.Subquery;
import org.jetbrains.annotations.NotNull;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.notSupportedOperation;
import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.requireBoolExpression;
import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.requireBoolExpressions;
import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.requireProperty;

/**
 * Abstract {@link jakarta.persistence.criteria.CriteriaBuilder} implementation.
 *
 * @author Denis Stepanov
 * @since 3.2
 */
@Internal
public abstract class AbstractCriteriaBuilder implements PersistentEntityCriteriaBuilder {

    @NotNull
    private Predicate predicate(Expression x, Expression y, PredicateBinaryOp op) {
        Objects.requireNonNull(x);
        Objects.requireNonNull(y);
        return new BinaryPredicate(x, y, op);
    }

    @NotNull
    @NextMajorVersion("Require non null y")
    private Predicate predicate(Expression x, Object y, PredicateBinaryOp op) {
        Objects.requireNonNull(x);
        return new BinaryPredicate(x, literal(y), op);
    }

    @NotNull
    private Predicate comparable(Expression x, Expression y, PredicateBinaryOp op) {
        return new BinaryPredicate(x, y, op);
    }

    @NotNull
    private Predicate comparable(Expression x, Object y, PredicateBinaryOp op) {
        return new BinaryPredicate(x, literal(Objects.requireNonNull(y)), op);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  CompoundSelection construct(@NonNull Class resultClass, @NonNull Selection... selections) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public CompoundSelection tuple(@NonNull Selection... selections) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public CompoundSelection array(@NonNull Selection... selections) {
        throw notSupportedOperation();
    }

    @Override
    @NonNull
    public Order asc(@NonNull Expression x) {
        return new PersistentPropertyOrder<>(requireProperty(x), true);
    }

    @Override
    @NonNull
    public Order desc(@NonNull Expression x) {
        return new PersistentPropertyOrder<>(requireProperty(x), false);
    }

    @Override
    @NonNull
    public  Expression avg(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.AVG);
    }

    @Override
    @NonNull
    public  Expression sum(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.SUM);
    }

    @Override
    @NonNull
    public Expression sumAsLong(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.SUM, Long.class);
    }

    @Override
    @NonNull
    public Expression sumAsDouble(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.SUM, Double.class);
    }

    @Override
    @NonNull
    public  Expression max(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.MAX);
    }

    @Override
    @NonNull
    public  Expression min(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.MIN);
    }

    @Override
    @NonNull
    public > Expression greatest(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.MAX);
    }

    @Override
    @NonNull
    public > Expression least(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.MIN);
    }

    @Override
    @NonNull
    public Expression count(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.COUNT, Long.class);
    }

    @Override
    @NonNull
    public Expression countDistinct(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.COUNT_DISTINCT, Long.class);
    }

    @Override
    @NonNull
    public Predicate exists(@NonNull Subquery subquery) {
        return new ExistsSubqueryPredicate(CriteriaUtils.requirePersistentEntitySubquery(subquery));
    }

    @Override
    @NonNull
    public  Expression all(@NonNull Subquery subquery) {
        return new SubqueryExpression<>(SubqueryExpression.Type.ALL, CriteriaUtils.requirePersistentEntitySubquery(subquery));
    }

    @Override
    @NonNull
    public  Expression some(@NonNull Subquery subquery) {
        return new SubqueryExpression<>(SubqueryExpression.Type.SOME, CriteriaUtils.requirePersistentEntitySubquery(subquery));
    }

    @Override
    @NonNull
    public  Expression any(@NonNull Subquery subquery) {
        return new SubqueryExpression<>(SubqueryExpression.Type.ANY, CriteriaUtils.requirePersistentEntitySubquery(subquery));
    }

    @Override
    @NonNull
    public Predicate and(@NonNull Expression x, @NonNull Expression y) {
        return new ConjunctionPredicate(List.of(requireBoolExpression(x), requireBoolExpression(y)));
    }

    @Override
    @NonNull
    public Predicate and(@NonNull Predicate... restrictions) {
        return and(List.of(restrictions));
    }

    @Override
    @NonNull
    public Predicate and(@NonNull Iterable restrictions) {
        return new ConjunctionPredicate(requireBoolExpressions(restrictions));
    }

    @Override
    @NonNull
    public Predicate isEmptyString(@NonNull Expression expression) {
        return new UnaryPredicate(expression, PredicateUnaryOp.IS_EMPTY);
    }

    @Override
    @NonNull
    public Predicate isNotEmptyString(@NonNull Expression expression) {
        return new UnaryPredicate(expression, PredicateUnaryOp.IS_NOT_EMPTY);
    }

    @Override
    @NonNull
    public Predicate ilike(@NonNull Expression x, @NonNull Expression pattern) {
        return new LikePredicate(x, pattern, null, false, true);
    }

    @Override
    public Predicate endingWithString(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.ENDS_WITH);
    }

    @Override
    @NonNull
    public Predicate startsWithString(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.STARTS_WITH);
    }

    @Override
    @NonNull
    public Predicate containsString(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.CONTAINS);
    }

    @Override
    public Predicate containsStringIgnoreCase(Expression x, Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.CONTAINS_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate equalStringIgnoreCase(@NonNull Expression x, @NonNull String y) {
        return new BinaryPredicate(x, literal(y), PredicateBinaryOp.EQUALS_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate equalStringIgnoreCase(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.EQUALS_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate notEqualStringIgnoreCase(@NonNull Expression x, @NonNull String y) {
        return new BinaryPredicate(x, literal(y), PredicateBinaryOp.NOT_EQUALS_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate notEqualStringIgnoreCase(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.NOT_EQUALS_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate startsWithStringIgnoreCase(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.STARTS_WITH_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate endingWithStringIgnoreCase(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.ENDS_WITH_IGNORE_CASE);
    }

    @Override
    @NonNull
    public Predicate or(@NonNull Expression x, @NonNull Expression y) {
        return new DisjunctionPredicate(List.of(requireBoolExpression(x), requireBoolExpression(y)));
    }

    @Override
    @NonNull
    public Predicate or(@NonNull Predicate... restrictions) {
        return or(List.of(restrictions));
    }

    @Override
    @NonNull
    public Predicate or(@NonNull Iterable restrictions) {
        return new DisjunctionPredicate(requireBoolExpressions(restrictions));
    }

    @Override
    @NonNull
    public Predicate not(@NonNull Expression restriction) {
        return new NegatedPredicate(requireBoolExpression(restriction));
    }

    @Override
    @NonNull
    public Predicate conjunction() {
        return new ConjunctionPredicate(Collections.emptyList());
    }

    @Override
    @NonNull
    public Predicate disjunction() {
        return new DisjunctionPredicate(Collections.emptyList());
    }

    @Override
    @NonNull
    public Predicate isTrue(@NonNull Expression x) {
        return new UnaryPredicate(x, PredicateUnaryOp.IS_TRUE);
    }

    @Override
    @NonNull
    public Predicate isFalse(@NonNull Expression x) {
        return new UnaryPredicate(x, PredicateUnaryOp.IS_FALSE);
    }

    @Override
    @NonNull
    public Predicate isNull(@NonNull Expression x) {
        return new UnaryPredicate(x, PredicateUnaryOp.IS_NULL);
    }

    @Override
    @NonNull
    public Predicate isNotNull(@NonNull Expression x) {
        return new UnaryPredicate(x, PredicateUnaryOp.IS_NON_NULL);
    }

    @Override
    @NonNull
    public Predicate equal(@NonNull Expression x, @NonNull Expression y) {
        return predicate(x, y, PredicateBinaryOp.EQUALS);
    }

    @Override
    @NonNull
    @NextMajorVersion("Don't allow null values")
    public Predicate equal(@NonNull Expression x, @Nullable Object y) {
        return predicate(x, y, PredicateBinaryOp.EQUALS);
    }

    @Override
    @NonNull
    public Predicate notEqual(@NonNull Expression x, @NonNull Expression y) {
        return predicate(x, y, PredicateBinaryOp.NOT_EQUALS);
    }

    @Override
    @NonNull
    public Predicate notEqual(@NonNull Expression x, @Nullable Object y) {
        return predicate(x, y, PredicateBinaryOp.NOT_EQUALS);
    }

    @Override
    @NonNull
    public > Predicate greaterThan(@NonNull Expression x, @NonNull Expression y) {
        return comparable(x, y, PredicateBinaryOp.GREATER_THAN);
    }

    @Override
    @NonNull
    public > Predicate greaterThan(@NonNull Expression x, @NonNull Y y) {
        return comparable(x, y, PredicateBinaryOp.GREATER_THAN);
    }

    @Override
    @NonNull
    public > Predicate greaterThanOrEqualTo(@NonNull Expression x, @NonNull Expression y) {
        return comparable(x, y, PredicateBinaryOp.GREATER_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public > Predicate greaterThanOrEqualTo(@NonNull Expression x, @NonNull Y y) {
        return comparable(x, y, PredicateBinaryOp.GREATER_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public > Predicate lessThan(@NonNull Expression x, @NonNull Expression y) {
        return comparable(x, y, PredicateBinaryOp.LESS_THAN);
    }

    @Override
    @NonNull
    public > Predicate lessThan(@NonNull Expression x, @NonNull Y y) {
        return comparable(x, y, PredicateBinaryOp.LESS_THAN);
    }

    @Override
    @NonNull
    public > Predicate lessThanOrEqualTo(@NonNull Expression x, @NonNull Expression y) {
        return comparable(x, y, PredicateBinaryOp.LESS_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public > Predicate lessThanOrEqualTo(@NonNull Expression x, Y y) {
        return comparable(x, y, PredicateBinaryOp.LESS_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public > Predicate between(@NonNull Expression v, @NonNull Expression x, @NonNull Expression y) {
        return new BetweenPredicate(v, x, y);
    }

    @Override
    @NonNull
    public > Predicate between(@NonNull Expression v, @NonNull Y x, @NonNull Y y) {
        return new BetweenPredicate(v, literal(Objects.requireNonNull(x)), literal(Objects.requireNonNull(y)));
    }

    @Override
    @NonNull
    public Predicate gt(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.GREATER_THAN);
    }

    @Override
    @NonNull
    public Predicate gt(@NonNull Expression x, @NonNull Number y) {
        return new BinaryPredicate(x, literal(Objects.requireNonNull(y)), PredicateBinaryOp.GREATER_THAN);
    }

    @Override
    @NonNull
    public Predicate ge(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.GREATER_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public Predicate ge(@NonNull Expression x, @NonNull Number y) {
        return new BinaryPredicate(x, literal(Objects.requireNonNull(y)), PredicateBinaryOp.GREATER_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public Predicate lt(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.LESS_THAN);
    }

    @Override
    @NonNull
    public Predicate lt(@NonNull Expression x, @NonNull Number y) {
        return new BinaryPredicate(x, literal(Objects.requireNonNull(y)), PredicateBinaryOp.LESS_THAN);
    }

    @Override
    @NonNull
    public Predicate le(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryPredicate(x, y, PredicateBinaryOp.LESS_THAN_OR_EQUALS);
    }

    @Override
    @NonNull
    public Predicate le(@NonNull Expression x, @NonNull Number y) {
        return new BinaryPredicate(x, literal(Objects.requireNonNull(y)), PredicateBinaryOp.LESS_THAN_OR_EQUALS);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression neg(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression abs(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    @Override
    @NonNull
    public  Expression sum(@NonNull Expression x, Expression y) {
        return new BinaryExpression<>(x, y, BinaryExpressionType.SUM, (Class) Number.class);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression sum(@NonNull Expression x, @NonNull N y) {
        return new BinaryExpression<>(x, literal(y), BinaryExpressionType.SUM, (Class) Number.class);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression sum(@NonNull N x, @NonNull Expression y) {
        return new BinaryExpression<>(literal(x), y, BinaryExpressionType.SUM, (Class) Number.class);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression prod(@NonNull Expression x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression prod(@NonNull Expression x, @NonNull N y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression prod(@NonNull N x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression diff(@NonNull Expression x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression diff(@NonNull Expression x, @NonNull N y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public  Expression diff(@NonNull N x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression quot(@NonNull Expression x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression quot(@NonNull Expression x, @NonNull Number y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression quot(@NonNull Number x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression mod(@NonNull Expression x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    public Expression mod(@NonNull Expression x, @NonNull Integer y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression mod(@NonNull Integer x, @NonNull Expression y) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression sqrt(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toLong(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toInteger(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toFloat(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toDouble(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toBigDecimal(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toBigInteger(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression toString(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    @Override
    @NonNull
    public  Expression literal(@Nullable T value) {
        return new LiteralExpression<>(value);
    }

    @Override
    @NonNull
    public  Expression nullLiteral(@NonNull Class x) {
        return new LiteralExpression<>(x);
    }

    @Override
    @NonNull
    public  ParameterExpression parameter(@NonNull Class paramClass) {
        return parameter(paramClass, null, null);
    }

    @Override
    public  ParameterExpression parameter(@NonNull Class paramClass, @NonNull String name) {
        return parameter(paramClass, name, null);
    }

    /**
     * Create a new parameter with possible constant value.
     *
     * @param paramClass The param class
     * @param name       The param name
     * @param value      The param value
     * @param         The param type
     * @return the parameter expression
     */
    @NonNull
    public  ParameterExpression parameter(@NonNull Class paramClass, @Nullable String name, @Nullable Object value) {
        return new DefaultParameterExpression<>(paramClass, name, value);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Predicate isEmpty(@NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Predicate isNotEmpty(@NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Expression size(@NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Expression size(@NonNull C collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Predicate isMember(@NonNull Expression elem, @NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Predicate isMember(@NonNull E elem, @NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Predicate isNotMember(@NonNull Expression elem, @NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Predicate isNotMember(@NonNull E elem, @NonNull Expression collection) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Expression> values(@NonNull M map) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public > Expression> keys(@NonNull M map) {
        throw notSupportedOperation();
    }

    @Override
    @NonNull
    public Predicate regex(@NonNull Expression x, @NonNull Expression pattern) {
        return new BinaryPredicate(x, pattern, PredicateBinaryOp.REGEX);
    }

    @Override
    @NonNull
    public Predicate like(@NonNull Expression x, @NonNull Expression pattern) {
        return new LikePredicate(x, pattern, null, false);
    }

    @Override
    @NonNull
    public Predicate like(@NonNull Expression x, @NonNull String pattern) {
        return new LikePredicate(x, literal(pattern), null, false);
    }

    @Override
    @NonNull
    public Predicate like(@NonNull Expression x, @NonNull Expression pattern, @NonNull Expression escapeChar) {
        return new LikePredicate(x, pattern, escapeChar, false);
    }

    @Override
    @NonNull
    public Predicate like(@NonNull Expression x, @NonNull Expression pattern, char escapeChar) {
        return new LikePredicate(x, pattern, literal(escapeChar), false);
    }

    @Override
    @NonNull
    public Predicate like(@NonNull Expression x, @NonNull String pattern, @NonNull Expression escapeChar) {
        return new LikePredicate(x, literal(pattern), escapeChar, false);
    }

    @Override
    @NonNull
    public Predicate like(@NonNull Expression x, @NonNull String pattern, char escapeChar) {
        return new LikePredicate(x, literal(pattern), literal(escapeChar), false);
    }

    @Override
    @NonNull
    public Predicate notLike(@NonNull Expression x, @NonNull Expression pattern) {
        return new LikePredicate(x, pattern, null, true);
    }

    @Override
    @NonNull
    public Predicate notLike(@NonNull Expression x, @NonNull String pattern) {
        return new LikePredicate(x, literal(pattern), null, true);
    }

    @Override
    @NonNull
    public Predicate notLike(@NonNull Expression x, @NonNull Expression pattern, @NonNull Expression escapeChar) {
        return new LikePredicate(x, pattern, escapeChar, true);
    }

    @Override
    @NonNull
    public Predicate notLike(@NonNull Expression x, @NonNull Expression pattern, char escapeChar) {
        return new LikePredicate(x, pattern, literal(escapeChar), true);
    }

    @Override
    @NonNull
    public Predicate notLike(@NonNull Expression x, @NonNull String pattern, @NonNull Expression escapeChar) {
        return new LikePredicate(x, literal(pattern), escapeChar, true);
    }

    @Override
    @NonNull
    public Predicate notLike(@NonNull Expression x, @NonNull String pattern, char escapeChar) {
        return new LikePredicate(x, literal(pattern), literal(escapeChar), true);
    }

    @Override
    @NonNull
    public Expression concat(@NonNull Expression x, @NonNull Expression y) {
        return new BinaryExpression<>(x, y, BinaryExpressionType.CONCAT, String.class);
    }

    @Override
    @NonNull
    public Expression concat(@NonNull Expression x, @NonNull String y) {
        return new BinaryExpression<>(x, literal(y), BinaryExpressionType.CONCAT, String.class);
    }

    @Override
    @NonNull
    public Expression concat(@NonNull String x, @NonNull Expression y) {
        return new BinaryExpression<>(literal(x), y, BinaryExpressionType.CONCAT, String.class);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression substring(@NonNull Expression x, @NonNull Expression from) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression substring(@NonNull Expression x, int from) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression substring(@NonNull Expression x, @NonNull Expression from, @NonNull Expression len) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression substring(@NonNull Expression x, int from, int len) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression trim(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression trim(@NonNull Trimspec ts, @NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression trim(@NonNull Expression t, @NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression trim(@NonNull Trimspec ts, @NonNull Expression t, @NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression trim(char t, @NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression trim(@NonNull Trimspec ts, char t, @NonNull Expression x) {
        throw notSupportedOperation();
    }

    @Override
    @NonNull
    public Expression lower(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.LOWER);
    }

    @Override
    @NonNull
    public Expression upper(@NonNull Expression x) {
        return new UnaryExpression<>(x, UnaryExpressionType.UPPER);
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression length(@NonNull Expression x) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression locate(@NonNull Expression x, @NonNull Expression pattern) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression locate(@NonNull Expression x, @NonNull String pattern) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression locate(@NonNull Expression x, @NonNull Expression pattern, @NonNull Expression from) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression locate(@NonNull Expression x, @NonNull String pattern, int from) {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression currentDate() {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression currentTimestamp() {
        throw notSupportedOperation();
    }

    /**
     * Not supported yet.
     *
     * {@inheritDoc}
     */
    @Override
    @NonNull
    public Expression




© 2015 - 2025 Weber Informatics LLC | Privacy Policy