Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2018 Sun.Hao
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package lodsve.mybatis.utils;
import lodsve.core.utils.StringUtils;
import lodsve.mybatis.dialect.Dialect;
import lodsve.mybatis.query.MyBatisSqlQuery;
import org.apache.ibatis.binding.MapperMethod;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.MappedStatement.Builder;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.mapping.SqlSource;
import org.springframework.data.domain.Sort;
import org.springframework.util.Assert;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
/**
* mybatis分页工具类.
*
* @author sunhao([email protected])
* @date 15/6/29 下午2:55
*/
public class PaginationUtils {
private static final Pattern ORDER_BY = Pattern.compile(".*order\\s+by\\s+.*", Pattern.CASE_INSENSITIVE);
private PaginationUtils() {
}
/**
* 从MappedStatement的参数中指定类型的参数
*
* @param parameter
* @param target
* @param
* @return
*/
@SuppressWarnings("unchecked")
public static T findObjectFromParameter(Object parameter, Class target) {
if (parameter == null || target == null) {
return null;
}
if (target.isAssignableFrom(parameter.getClass())) {
return (T) parameter;
}
if (parameter instanceof MapperMethod.ParamMap) {
MapperMethod.ParamMap