package com.vci.ubcs.codeapply.object; import java.io.Serializable; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; public interface IPage extends Serializable { List orders(); default boolean optimizeCountSql() { return true; } default boolean optimizeJoinOfCountSql() { return true; } default boolean searchCount() { return true; } default long offset() { long current = this.getCurrent(); return current <= 1L ? 0L : Math.max((current - 1L) * this.getSize(), 0L); } default Long maxLimit() { return null; } default long getPages() { if (this.getSize() == 0L) { return 0L; } else { long pages = this.getTotal() / this.getSize(); if (this.getTotal() % this.getSize() != 0L) { ++pages; } return pages; } } default IPage setPages(long pages) { return this; } List getRecords(); IPage setRecords(List records); long getTotal(); IPage setTotal(long total); long getSize(); IPage setSize(long size); long getCurrent(); IPage setCurrent(long current); default IPage convert(Function mapper) { List collect = (List)this.getRecords().stream().map(mapper).collect(Collectors.toList()); return this.setRecords(collect); } default String countId() { return null; } }