2
0
mirror of https://github.com/TeamNewPipe/NewPipeExtractor synced 2025-08-30 05:47:41 +00:00

Merge pull request #1313 from asifebrahim/temp

Add Nullable annotations in ListExtractor
This commit is contained in:
Tobi 2025-07-07 11:56:00 -07:00 committed by GitHub
commit 48d78205be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,7 +8,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* Base class to extractors that have a list (e.g. playlists, users). * Base class to extractors that have a list (e.g. playlists, users).
@ -20,11 +20,13 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
* a list has an unknown number of items. * a list has an unknown number of items.
*/ */
public static final long ITEM_COUNT_UNKNOWN = -1; public static final long ITEM_COUNT_UNKNOWN = -1;
/** /**
* Constant that should be returned whenever a list has an * Constant that should be returned whenever a list has an
* infinite number of items. For example a YouTube mix. * infinite number of items. For example a YouTube mix.
*/ */
public static final long ITEM_COUNT_INFINITE = -2; public static final long ITEM_COUNT_INFINITE = -2;
/** /**
* Constant that should be returned whenever a list * Constant that should be returned whenever a list
* has an unknown number of items bigger than 100. * has an unknown number of items bigger than 100.
@ -69,8 +71,11 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
* @param <T> the info item type that this page is supposed to store and provide * @param <T> the info item type that this page is supposed to store and provide
*/ */
public static class InfoItemsPage<T extends InfoItem> { public static class InfoItemsPage<T extends InfoItem> {
private static final InfoItemsPage<InfoItem> EMPTY = private static final InfoItemsPage<InfoItem> EMPTY = new InfoItemsPage<>(
new InfoItemsPage<>(Collections.emptyList(), null, Collections.emptyList()); Collections.emptyList(),
null,
Collections.emptyList()
);
/** /**
* A convenient method that returns a representation of an empty page. * A convenient method that returns a representation of an empty page.
@ -94,6 +99,7 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
* @see ListExtractor#getPage(Page) * @see ListExtractor#getPage(Page)
* @see Page * @see Page
*/ */
@Nullable
private final Page nextPage; private final Page nextPage;
/** /**
@ -101,12 +107,13 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
*/ */
private final List<Throwable> errors; 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()); this(collector.getItems(), nextPage, collector.getErrors());
} }
public InfoItemsPage(final List<T> itemsList, public InfoItemsPage(final List<T> itemsList,
final Page nextPage, @Nullable final Page nextPage,
final List<Throwable> errors) { final List<Throwable> errors) {
this.itemsList = itemsList; this.itemsList = itemsList;
this.nextPage = nextPage; this.nextPage = nextPage;
@ -121,6 +128,10 @@ public abstract class ListExtractor<R extends InfoItem> extends Extractor {
return itemsList; return itemsList;
} }
/**
* @return the next page if available, or null otherwise
*/
@Nullable
public Page getNextPage() { public Page getNextPage() {
return nextPage; return nextPage;
} }