com.itcoon.common.jpa.page.JpaPageResult Maven / Gradle / Ivy
package com.itcoon.common.jpa.page;
import com.itcoon.common.core.page.AbstractPageResultAdaptor;
import com.itcoon.common.core.page.PageResult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import java.util.List;
public class JpaPageResult extends AbstractPageResultAdaptor> {
public static JpaPageResult of(List content, Pageable pageable,long total){
return new JpaPageResult<>(new PageImpl<>(content, pageable, total));
}
public static JpaPageResult of(Page page){
return new JpaPageResult<>(page);
}
private JpaPageResult(Page page) {
super(page);
}
@Override
public List getContents() {
return getPage().getContent();
}
@Override
public Integer getPageNo() {
return getPage().getPageable().getPageNumber() + 1;
}
@Override
public Integer getPageSize() {
return getPage().getPageable().getPageSize();
}
@Override
public Long getTotal() {
return getPage().getTotalElements();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy