top.springdatajpa.zujijpa.utils.JpaHelper Maven / Gradle / Ivy
package top.springdatajpa.zujijpa.utils;
import lombok.experimental.UtilityClass;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import java.util.List;
/**
*
* JPA Helper
*
*
* @author azheng
* @since 2019-10-10
*/
@UtilityClass
public class JpaHelper {
public Page castPage(Page> pageList, PageRequest page, Class toClass){
List result = EntityUtils.cast(pageList.getContent(), toClass);
return new PageImpl(result, page, pageList.getTotalElements());
}
}