Skip to content

Commit

Permalink
rename #asPage() to #paginate()
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Sep 30, 2024
1 parent 1ff9d9b commit dbd1fc2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.List;

/**
* Thrown when an invalid page is passed to {@link CommandList#asPage(int, int)}
* Thrown when an invalid page is passed to {@link CommandList#paginate(int, int)}
*/
@ThrowableFromCommand
public class InvalidHelpPageException extends RuntimeException {
Expand Down
24 changes: 23 additions & 1 deletion common/src/main/java/revxrsal/commands/help/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,31 @@ interface CommandList<A extends CommandActor> extends Iterable<ExecutableCommand
* @return The pages list.
* @throws InvalidHelpPageException if {@code pageNumber} is greater than
* {@link #numberOfPages(int)} or less than 1
* @deprecated Use {@link #paginate(int, int)} instead.
*/
@Unmodifiable
List<ExecutableCommand<A>> asPage(
@Deprecated(forRemoval = true)
default List<ExecutableCommand<A>> asPage(
@Range(from = 1, to = Integer.MAX_VALUE) int pageNumber,
@Range(from = 1, to = Integer.MAX_VALUE) int elementsPerPage
) throws InvalidHelpPageException {
return paginate(pageNumber, elementsPerPage);
}

/**
* Returns the list of commands that belong to a specific page after paginating
* this list.
* <p>
* Note that the list returned by this method is immutable.
*
* @param pageNumber The page number
* @param elementsPerPage The elements to include in each page
* @return The pages list.
* @throws InvalidHelpPageException if {@code pageNumber} is greater than
* {@link #numberOfPages(int)} or less than 1
*/
@Unmodifiable
List<ExecutableCommand<A>> paginate(
@Range(from = 1, to = Integer.MAX_VALUE) int pageNumber,
@Range(from = 1, to = Integer.MAX_VALUE) int elementsPerPage
) throws InvalidHelpPageException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import java.util.Iterator;
import java.util.List;

import static revxrsal.commands.help.Help.paginate;

final class HelpImpl {

static abstract class CommandListImpl<A extends CommandActor> implements Help.CommandList<A> {
Expand All @@ -52,8 +50,8 @@ public CommandListImpl(@Unmodifiable List<ExecutableCommand<A>> commands) {
return commands;
}

@Override public @Unmodifiable List<ExecutableCommand<A>> asPage(int pageNumber, int elementsPerPage) {
return paginate(commands, pageNumber, elementsPerPage);
@Override public @Unmodifiable List<ExecutableCommand<A>> paginate(int pageNumber, int elementsPerPage) {
return Help.paginate(commands, pageNumber, elementsPerPage);
}

@Override public @NotNull Iterator<ExecutableCommand<A>> iterator() {
Expand Down

0 comments on commit dbd1fc2

Please sign in to comment.