Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

import javax.annotation.Nonnull;

import javax.annotation.Nullable;

/**
* Base class to extractors that have a list (e.g. playlists, users).
Expand All @@ -20,11 +20,13 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
* a list has an unknown number of items.
*/
public static final long ITEM_COUNT_UNKNOWN = -1;

/**
* Constant that should be returned whenever a list has an
* infinite number of items. For example a YouTube mix.
*/
public static final long ITEM_COUNT_INFINITE = -2;

/**
* Constant that should be returned whenever a list
* has an unknown number of items bigger than 100.
Expand Down Expand Up @@ -69,8 +71,11 @@ public ListLinkHandler getLinkHandler() {
* @param <T> the info item type that this page is supposed to store and provide
*/
public static class InfoItemsPage<T extends InfoItem> {
private static final InfoItemsPage<InfoItem> EMPTY =
new InfoItemsPage<>(Collections.emptyList(), null, Collections.emptyList());
private static final InfoItemsPage<InfoItem> EMPTY = new InfoItemsPage<>(
Collections.emptyList(),
null,
Collections.emptyList()
);

/**
* A convenient method that returns a representation of an empty page.
Expand All @@ -94,19 +99,21 @@ public static <T extends InfoItem> InfoItemsPage<T> emptyPage() {
* @see ListExtractor#getPage(Page)
* @see Page
*/
@Nullable
private final Page nextPage;

/**
* Errors that happened during the extraction
*/
private final List<Throwable> errors;

public InfoItemsPage(final InfoItemsCollector<T, ?> collector, final Page nextPage) {
public InfoItemsPage(final InfoItemsCollector<T, ?> collector,
@Nullable final Page nextPage) {
this(collector.getItems(), nextPage, collector.getErrors());
}

public InfoItemsPage(final List<T> itemsList,
final Page nextPage,
@Nullable final Page nextPage,
final List<Throwable> errors) {
this.itemsList = itemsList;
this.nextPage = nextPage;
Expand All @@ -121,6 +128,10 @@ public List<T> getItems() {
return itemsList;
}

/**
* @return the next page if available, or null otherwise
*/
@Nullable
public Page getNextPage() {
return nextPage;
}
Expand Down
Loading