use JsonObject#isEmpty instead of JsonObject#equals(JsonUtils.EMPTY_OBJECT)

This commit is contained in:
bopol 2020-05-07 15:32:25 +02:00
parent 93e868634e
commit 5760366d70
2 changed files with 7 additions and 7 deletions

View File

@ -130,7 +130,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
public String getSearchSuggestion() throws ParsingException { public String getSearchSuggestion() throws ParsingException {
final JsonObject itemSectionRenderer = initialData.getObject("contents").getObject("sectionListRenderer") final JsonObject itemSectionRenderer = initialData.getObject("contents").getObject("sectionListRenderer")
.getArray("contents").getObject(0).getObject("itemSectionRenderer"); .getArray("contents").getObject(0).getObject("itemSectionRenderer");
if (itemSectionRenderer.equals(JsonUtils.EMPTY_OBJECT)) { if (itemSectionRenderer.isEmpty()) {
return ""; return "";
} }
@ -139,9 +139,9 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
final JsonObject showingResultsForRenderer = itemSectionRenderer.getArray("contents").getObject(0) final JsonObject showingResultsForRenderer = itemSectionRenderer.getArray("contents").getObject(0)
.getObject("showingResultsForRenderer"); .getObject("showingResultsForRenderer");
if (!didYouMeanRenderer.equals(JsonUtils.EMPTY_OBJECT)) { if (!didYouMeanRenderer.isEmpty()) {
return getTextFromObject(didYouMeanRenderer.getObject("correctedQuery")); return getTextFromObject(didYouMeanRenderer.getObject("correctedQuery"));
} else if (!showingResultsForRenderer.equals(JsonUtils.EMPTY_OBJECT)) { } else if (!showingResultsForRenderer.isEmpty()) {
return JsonUtils.getString(showingResultsForRenderer, "correctedQueryEndpoint.searchEndpoint.query"); return JsonUtils.getString(showingResultsForRenderer, "correctedQueryEndpoint.searchEndpoint.query");
} else { } else {
return ""; return "";
@ -152,13 +152,13 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
public boolean isCorrectedSearch() { public boolean isCorrectedSearch() {
final JsonObject itemSectionRenderer = initialData.getObject("contents").getObject("sectionListRenderer") final JsonObject itemSectionRenderer = initialData.getObject("contents").getObject("sectionListRenderer")
.getArray("contents").getObject(0).getObject("itemSectionRenderer"); .getArray("contents").getObject(0).getObject("itemSectionRenderer");
if (itemSectionRenderer.equals(JsonUtils.EMPTY_OBJECT)) { if (itemSectionRenderer.isEmpty()) {
return false; return false;
} }
final JsonObject showingResultsForRenderer = itemSectionRenderer.getArray("contents").getObject(0) final JsonObject showingResultsForRenderer = itemSectionRenderer.getArray("contents").getObject(0)
.getObject("showingResultsForRenderer"); .getObject("showingResultsForRenderer");
return !showingResultsForRenderer.equals(JsonUtils.EMPTY_OBJECT); return !showingResultsForRenderer.isEmpty();
} }
@Nonnull @Nonnull

View File

@ -73,7 +73,7 @@ public class YoutubeSearchExtractor extends SearchExtractor {
final JsonObject showingResultsForRenderer = itemSectionRenderer.getArray("contents").getObject(0) final JsonObject showingResultsForRenderer = itemSectionRenderer.getArray("contents").getObject(0)
.getObject("showingResultsForRenderer"); .getObject("showingResultsForRenderer");
if (!didYouMeanRenderer.equals(JsonUtils.EMPTY_OBJECT)) { if (!didYouMeanRenderer.isEmpty()) {
return JsonUtils.getString(didYouMeanRenderer, "correctedQueryEndpoint.searchEndpoint.query"); return JsonUtils.getString(didYouMeanRenderer, "correctedQueryEndpoint.searchEndpoint.query");
} else if (showingResultsForRenderer != null) { } else if (showingResultsForRenderer != null) {
return getTextFromObject(showingResultsForRenderer.getObject("correctedQuery")); return getTextFromObject(showingResultsForRenderer.getObject("correctedQuery"));
@ -89,7 +89,7 @@ public class YoutubeSearchExtractor extends SearchExtractor {
.getObject("sectionListRenderer").getArray("contents").getObject(0) .getObject("sectionListRenderer").getArray("contents").getObject(0)
.getObject("itemSectionRenderer").getArray("contents").getObject(0) .getObject("itemSectionRenderer").getArray("contents").getObject(0)
.getObject("showingResultsForRenderer"); .getObject("showingResultsForRenderer");
return !showingResultsForRenderer.equals(JsonUtils.EMPTY_OBJECT); return !showingResultsForRenderer.isEmpty();
} }
@Nonnull @Nonnull