001package com.ericlam.mc.eld.configurations; 002 003import java.util.List; 004import java.util.function.Function; 005 006/** 007 * 頁面 (參考了 Spring Data Page) 008 * @param <T> 元素類型 009 */ 010public interface Page<T> { 011 012 /** 013 * 獲取本頁的所有內容 014 * @return 所有內容 015 */ 016 List<T> getContent(); 017 018 /** 019 * 020 * @return 是否有內容 021 */ 022 boolean hasContent(); 023 024 /** 025 * 獲取目前頁面數 026 * @return 頁面數 027 */ 028 int getCurrentPage(); 029 030 /** 031 * 獲取總共頁面數 032 * @return 總共頁面數 033 */ 034 int getTotalPages(); 035 036 /** 037 * 是否有下一頁 038 * @return this 039 */ 040 boolean hasNext(); 041 042 /** 043 * 是否有上一頁 044 * @return this 045 */ 046 boolean hasPrevious(); 047 048 /** 049 * 獲取所有頁面加起來的總共數量 050 * @return 總共數量 051 */ 052 long getTotalElements(); 053 054 /** 055 * 獲取頁面請求 056 * @return 頁面請求 057 */ 058 PageRequest getPageRequest(); 059 060 /** 061 * 轉換形態用 062 * @param converter 轉換 063 * @param <U> 新形態 064 * @return this 065 */ 066 <U> Page<U> map(Function<T, U> converter); 067 068}