top.openyuan.jpa.specification.handler.impl.NotInPredicateHandler Maven / Gradle / Ivy
package top.openyuan.jpa.specification.handler.impl;
import top.openyuan.jpa.specification.annotation.NotIn;
import top.openyuan.jpa.specification.handler.AbstractPredicateHandler;
import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
import top.openyuan.jpa.specification.predicate.AbstractSimplePredicateExt;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collection;
/**
* 构建“范围不匹配条件”({@code field NOT IN ('xxx', 'yyy')})场景的 {@link Predicate} 处理器.
*
* @author lzy
* @since v1.0.0
*/
public class NotInPredicateHandler extends AbstractPredicateHandler {
@Override
public Class getAnnotation() {
return NotIn.class;
}
@Override
public Predicate buildPredicate(
CriteriaBuilder criteriaBuilder, From from, String fieldName, Object value, Annotation annotation) {
return this.buildPredicate(criteriaBuilder, from, fieldName, value);
}
@Override
public Predicate buildPredicate(
CriteriaBuilder criteriaBuilder, From, ?> from, String fieldName, Object value) {
CriteriaBuilder.In