-
Notifications
You must be signed in to change notification settings - Fork 21
/
Pagination.java
114 lines (99 loc) · 3.23 KB
/
Pagination.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package me.devnatan.inventoryframework.component;
import me.devnatan.inventoryframework.state.StateHandler;
import me.devnatan.inventoryframework.state.StateHost;
import org.jetbrains.annotations.Nullable;
/**
* Pagination is a host to multiple components that can be paginated, essentially it is a {@link
* me.devnatan.inventoryframework.component.ComponentComposition} divided into sections called
* <i>pages</i>.
*
* <p>It's a "malformed" structure from a data rendering point of view, that is, the components from
* its minimum slot position to its maximum slot position may or may not be part of your
* composition.
*
* <p>This component has an internal state used to control which <i>page</i> will be displayed
* during rendering, this component is determined from the {@link #currentPageIndex() current page
* index}.
*/
public interface Pagination extends StateHandler, ComponentComposition {
/**
* The current page number.
*
* @return The current page number. Returns {@code 1} if it's in the first page.
*/
int currentPage();
/**
* The index of the current page.
*
* @return The index of the current page. Returns {@code 0} if it's in the first page.
*/
int currentPageIndex();
/**
* The number of the last page.
* <p>
* This is a shortcut to {@link #lastPageIndex()} {@code + 1}.
*
* @return The number of the last page.
*/
int lastPage();
/**
* The index of the last page.
* <p>
* Pages starts from {@code 0} so the last page should be displayed as {@code lastPage + 1}.
*
* @return The index of the last page.
*/
int lastPageIndex();
/**
* Checks if the {@link #currentPage() current page} is the first page (at index 0).
*
* @return If the current page is the first page.
*/
boolean isFirstPage();
/**
* Checks if the {@link #currentPage() current page} is the last page (at {@link #lastPage()}).
*
* @return If the current page is the first page.
*/
boolean isLastPage();
/**
* Checks for pages before the current page.
*
* @return {@code true} if there are previous pages or {@code false} otherwise.
*/
boolean hasPreviousPage();
/**
* Checks for pages after the current page.
*
* @return {@code true} if there are next pages or {@code false} otherwise.
*/
boolean hasNextPage();
/**
* Advances to the next page if available.
*/
void advance();
/**
* Checks for pages to advance.
*
* @return {@code true} if there are pages to advance or {@code false} otherwise.
*/
boolean canAdvance();
/**
* Backs to the previous page if available.
*/
void back();
/**
* Checks for pages to back.
*
* @return {@code true} if there are pages to back or {@code false} otherwise.
*/
boolean canBack();
/**
* Layout target character that determines the boundary positions that this component should be
* rendered. Used if there is more than one pagination component sharing the same {@link StateHost}.
*
* @return The layout character target if set or {@code null}.
*/
@Nullable
String getLayoutTarget();
}