Apply suggestions: improve switch and use EMPTY_STRING

This commit is contained in:
Stypox 2022-04-30 16:39:51 +02:00
parent 8c1041def6
commit c2b5370517
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 8 additions and 8 deletions

View File

@ -18,6 +18,7 @@ import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.streaminfoitem.BandcampSearchStreamInfoItemExtractor;
import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import java.io.IOException;
@ -34,7 +35,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
@NonNull
@Override
public String getSearchSuggestion() {
return "";
return Utils.EMPTY_STRING;
}
@Override
@ -58,13 +59,9 @@ public class BandcampSearchExtractor extends SearchExtractor {
.flatMap(element -> element.getElementsByClass("itemtype").stream())
.map(Element::text)
.findFirst()
.orElse("");
.orElse(Utils.EMPTY_STRING);
switch (type) {
default:
case "FAN":
// don't display fan results
break;
case "ARTIST":
collector.commit(new BandcampChannelInfoItemExtractor(searchResult));
break;
@ -74,6 +71,9 @@ public class BandcampSearchExtractor extends SearchExtractor {
case "TRACK":
collector.commit(new BandcampSearchStreamInfoItemExtractor(searchResult, null));
break;
default:
// don't display fan results ("FAN") or other things
break;
}
}

View File

@ -119,7 +119,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Override
public String getThumbnailUrl() throws ParsingException {
if (albumJson.isNull("art_id")) {
return "";
return Utils.EMPTY_STRING;
} else {
return getImageUrl(albumJson.getLong("art_id"), true);
}
@ -131,7 +131,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
return document.getElementsByClass("band-photo").stream()
.map(element -> element.attr("src"))
.findFirst()
.orElse("");
.orElse(Utils.EMPTY_STRING);
}
@Nonnull