mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 14:20:33 +05:30
Merge pull request #419 from Isira-Seneviratne/Use_Objects_methods
Use Objects methods.
This commit is contained in:
commit
2b622fd2f1
@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class Extractor {
|
||||
/**
|
||||
@ -29,12 +30,9 @@ public abstract class Extractor {
|
||||
private final Downloader downloader;
|
||||
|
||||
public Extractor(final StreamingService service, final LinkHandler linkHandler) {
|
||||
if (service == null) throw new NullPointerException("service is null");
|
||||
if (linkHandler == null) throw new NullPointerException("LinkHandler is null");
|
||||
this.service = service;
|
||||
this.linkHandler = linkHandler;
|
||||
this.downloader = NewPipe.getDownloader();
|
||||
if (downloader == null) throw new NullPointerException("downloader is null");
|
||||
this.service = Objects.requireNonNull(service, "service is null");
|
||||
this.linkHandler = Objects.requireNonNull(linkHandler, "LinkHandler is null");
|
||||
this.downloader = Objects.requireNonNull(NewPipe.getDownloader(), "downloader is null");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Localization implements Serializable {
|
||||
public static final Localization DEFAULT = new Localization("en", "GB");
|
||||
@ -89,14 +90,14 @@ public class Localization implements Serializable {
|
||||
|
||||
Localization that = (Localization) o;
|
||||
|
||||
if (!languageCode.equals(that.languageCode)) return false;
|
||||
return countryCode != null ? countryCode.equals(that.countryCode) : that.countryCode == null;
|
||||
return languageCode.equals(that.languageCode) &&
|
||||
Objects.equals(countryCode, that.countryCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = languageCode.hashCode();
|
||||
result = 31 * result + (countryCode != null ? countryCode.hashCode() : 0);
|
||||
result = 31 * result + Objects.hashCode(countryCode);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse;
|
||||
@ -861,7 +862,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
return result == null ? "" : result.toString();
|
||||
return Objects.toString(result, "");
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user