top.openyuan.jpa.specification.handler.impl.LikeInPredicateHandler Maven / Gradle / Ivy
package top.openyuan.jpa.specification.handler.impl;
import top.openyuan.jpa.specification.annotation.LikeIn;
import top.openyuan.jpa.specification.handler.AbstractPredicateHandler;
import top.openyuan.jpa.common.util.CollectionUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;
import java.lang.annotation.Annotation;
import java.util.List;
/**
* 构建“模糊条件”({@code field LIKE '%xx%' OR field LIKE '%yyy%'})场景的 {@link Predicate} 处理器.
*
* @author lzy
* @since v1.0.0
*/
public class LikeInPredicateHandler extends AbstractPredicateHandler {
@Override
public Class getAnnotation() {
return LikeIn.class;
}
@Override
public Predicate buildPredicate(
CriteriaBuilder criteriaBuilder, From from, String fieldName, Object value, Annotation annotation) {
return this.buildPredicate(criteriaBuilder, from, fieldName, value);
}
@SuppressWarnings("unchecked")
@Override
public Predicate buildPredicate(
CriteriaBuilder criteriaBuilder, From, ?> from, String fieldName, Object value) {
Predicate p = null;
List