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