Skip to content

Commit de26e00

Browse files
committed
changed all == null || isEmpty() to isNullOrEmpty()
1 parent 202a735 commit de26e00

17 files changed

Lines changed: 55 additions & 37 deletions

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.IOException;
1919

2020
import static org.schabi.newpipe.extractor.utils.JsonUtils.EMPTY_STRING;
21+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2122

2223
@SuppressWarnings("WeakerAccess")
2324
public class SoundcloudChannelExtractor extends ChannelExtractor {
@@ -132,7 +133,7 @@ private void computeNextPageAndGetStreams() throws ExtractionException {
132133

133134
@Override
134135
public InfoItemsPage<StreamInfoItem> getPage(final String pageUrl) throws IOException, ExtractionException {
135-
if (pageUrl == null || pageUrl.isEmpty()) {
136+
if (isNullOrEmpty(pageUrl)) {
136137
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
137138
}
138139

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChartsExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.io.IOException;
1414

1515
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
16+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
1617

1718
public class SoundcloudChartsExtractor extends KioskExtractor<StreamInfoItem> {
1819
private StreamInfoItemsCollector collector = null;
@@ -36,7 +37,7 @@ public String getName() {
3637

3738
@Override
3839
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
39-
if (pageUrl == null || pageUrl.isEmpty()) {
40+
if (isNullOrEmpty(pageUrl)) {
4041
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
4142
}
4243

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public String getNextPageUrl() throws IOException, ExtractionException {
162162

163163
@Override
164164
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
165-
if (pageUrl == null || pageUrl.isEmpty()) {
165+
if (isNullOrEmpty(pageUrl)) {
166166
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
167167
}
168168

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint)
391391
* @return text in the JSON object or {@code null}
392392
*/
393393
public static String getTextFromObject(JsonObject textObject, boolean html) throws ParsingException {
394-
if (textObject == null || textObject.isEmpty()) return null;
394+
if (isNullOrEmpty(textObject)) return null;
395395

396396
if (textObject.has("simpleText")) return textObject.getString("simpleText");
397397

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException
245245

246246
@Override
247247
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
248-
if (pageUrl == null || pageUrl.isEmpty()) {
248+
if (isNullOrEmpty(pageUrl)) {
249249
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
250250
}
251251

@@ -266,7 +266,7 @@ public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException,
266266

267267

268268
private String getNextPageUrlFrom(JsonArray continuations) {
269-
if (continuations == null || continuations.isEmpty()) {
269+
if (isNullOrEmpty(continuations)) {
270270
return "";
271271
}
272272

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.regex.Pattern;
2828

2929
import static java.util.Collections.singletonList;
30+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
3031

3132

3233
public class YoutubeCommentsExtractor extends CommentsExtractor {
@@ -91,7 +92,7 @@ private String getNextPageUrl(String continuation) throws ParsingException {
9192

9293
@Override
9394
public InfoItemsPage<CommentsInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
94-
if (pageUrl == null || pageUrl.isEmpty()) {
95+
if (isNullOrEmpty(pageUrl)) {
9596
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
9697
}
9798
String ajaxResponse = makeAjaxRequest(pageUrl);

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSearchExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public String getNextPageUrl() throws ExtractionException, IOException {
167167

168168
@Override
169169
public InfoItemsPage<InfoItem> getPage(final String pageUrl) throws IOException, ExtractionException {
170-
if (pageUrl == null || pageUrl.isEmpty()) {
170+
if (isNullOrEmpty(pageUrl)) {
171171
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
172172
}
173173

@@ -470,7 +470,7 @@ public long getStreamCount() throws ParsingException {
470470
}
471471

472472
private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException, IOException, ReCaptchaException {
473-
if (continuations == null || continuations.isEmpty()) {
473+
if (isNullOrEmpty(continuations)) {
474474
return "";
475475
}
476476

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse;
2424
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
2525
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint;
26+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2627

2728
@SuppressWarnings("WeakerAccess")
2829
public class YoutubePlaylistExtractor extends PlaylistExtractor {
@@ -93,11 +94,11 @@ public String getThumbnailUrl() throws ParsingException {
9394
String url = playlistInfo.getObject("thumbnailRenderer").getObject("playlistVideoThumbnailRenderer")
9495
.getObject("thumbnail").getArray("thumbnails").getObject(0).getString("url");
9596

96-
if (url == null || url.isEmpty()) {
97+
if (isNullOrEmpty(url)) {
9798
url = initialData.getObject("microformat").getObject("microformatDataRenderer").getObject("thumbnail")
9899
.getArray("thumbnails").getObject(0).getString("url");
99100

100-
if (url == null || url.isEmpty()) throw new ParsingException("Could not get playlist thumbnail");
101+
if (isNullOrEmpty(url)) throw new ParsingException("Could not get playlist thumbnail");
101102
}
102103

103104
return fixThumbnailUrl(url);
@@ -166,7 +167,7 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() {
166167

167168
@Override
168169
public InfoItemsPage<StreamInfoItem> getPage(final String pageUrl) throws IOException, ExtractionException {
169-
if (pageUrl == null || pageUrl.isEmpty()) {
170+
if (isNullOrEmpty(pageUrl)) {
170171
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
171172
}
172173

@@ -182,7 +183,7 @@ public InfoItemsPage<StreamInfoItem> getPage(final String pageUrl) throws IOExce
182183
}
183184

184185
private String getNextPageUrlFrom(JsonArray continuations) {
185-
if (continuations == null || continuations.isEmpty()) {
186+
if (isNullOrEmpty(continuations)) {
186187
return "";
187188
}
188189

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse;
2121
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
22+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
2223

2324
/*
2425
* Created by Christian Schabesberger on 22.07.2018
@@ -99,7 +100,7 @@ public String getNextPageUrl() throws ExtractionException {
99100

100101
@Override
101102
public InfoItemsPage<InfoItem> getPage(final String pageUrl) throws IOException, ExtractionException {
102-
if (pageUrl == null || pageUrl.isEmpty()) {
103+
if (isNullOrEmpty(pageUrl)) {
103104
throw new ExtractionException(new IllegalArgumentException("Page url is empty or null"));
104105
}
105106

@@ -133,7 +134,7 @@ private void collectStreamsFrom(final InfoItemsSearchCollector collector, final
133134
}
134135

135136
private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException {
136-
if (continuations == null || continuations.isEmpty()) {
137+
if (isNullOrEmpty(continuations)) {
137138
return "";
138139
}
139140

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.*;
5656
import static org.schabi.newpipe.extractor.utils.JsonUtils.EMPTY_STRING;
57+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
5758

5859
/*
5960
* Created by Christian Schabesberger on 06.08.15.
@@ -116,10 +117,10 @@ public String getName() throws ParsingException {
116117
assertPageFetched();
117118
String title = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("title"));
118119

119-
if (title == null || title.isEmpty()) {
120+
if (isNullOrEmpty(title)) {
120121
title = playerResponse.getObject("videoDetails").getString("title");
121122

122-
if (title == null || title.isEmpty()) throw new ParsingException("Could not get name");
123+
if (isNullOrEmpty(title)) throw new ParsingException("Could not get name");
123124
}
124125

125126
return title;
@@ -167,7 +168,7 @@ public String getTextualUploadDate() throws ParsingException {
167168
public DateWrapper getUploadDate() throws ParsingException {
168169
final String textualUploadDate = getTextualUploadDate();
169170

170-
if (textualUploadDate == null || textualUploadDate.isEmpty()) {
171+
if (isNullOrEmpty(textualUploadDate)) {
171172
return null;
172173
}
173174

@@ -204,7 +205,7 @@ public Description getDescription() throws ParsingException {
204205

205206
@Override
206207
public int getAgeLimit() {
207-
if (initialData == null || initialData.isEmpty()) throw new IllegalStateException("initialData is not parsed yet");
208+
if (isNullOrEmpty(initialData)) throw new IllegalStateException("initialData is not parsed yet");
208209

209210
return ageLimit;
210211
}
@@ -248,10 +249,10 @@ public long getViewCount() throws ParsingException {
248249
String views = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("viewCount")
249250
.getObject("videoViewCountRenderer").getObject("viewCount"));
250251

251-
if (views == null || views.isEmpty()) {
252+
if (isNullOrEmpty(views)) {
252253
views = playerResponse.getObject("videoDetails").getString("viewCount");
253254

254-
if (views == null || views.isEmpty()) throw new ParsingException("Could not get view count");
255+
if (isNullOrEmpty(views)) throw new ParsingException("Could not get view count");
255256
}
256257

257258
if (views.toLowerCase().contains("no views")) return 0;
@@ -329,10 +330,10 @@ public String getUploaderName() throws ParsingException {
329330
String uploaderName = getTextFromObject(getVideoSecondaryInfoRenderer().getObject("owner")
330331
.getObject("videoOwnerRenderer").getObject("title"));
331332

332-
if (uploaderName == null || uploaderName.isEmpty()) {
333+
if (isNullOrEmpty(uploaderName)) {
333334
uploaderName = playerResponse.getObject("videoDetails").getString("author");
334335

335-
if (uploaderName == null || uploaderName.isEmpty()) throw new ParsingException("Could not get uploader name");
336+
if (isNullOrEmpty(uploaderName)) throw new ParsingException("Could not get uploader name");
336337
}
337338

338339
return uploaderName;

0 commit comments

Comments
 (0)