Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Objects.requireNonNull(). #877

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,8 @@ public Request(final String httpMethod,
@Nullable final byte[] dataToSend,
@Nullable final Localization localization,
final boolean automaticLocalizationHeader) {
if (httpMethod == null) {
throw new IllegalArgumentException("Request's httpMethod is null");
}
if (url == null) {
throw new IllegalArgumentException("Request's url is null");
}

this.httpMethod = httpMethod;
this.url = url;
this.httpMethod = Objects.requireNonNull(httpMethod, "Request's httpMethod is null");
this.url = Objects.requireNonNull(url, "Request's url is null");
this.dataToSend = dataToSend;
this.localization = localization;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Utils;

import java.util.Objects;

/*
* Created by Christian Schabesberger on 26.07.16.
*
Expand Down Expand Up @@ -72,9 +74,7 @@ public LinkHandler fromUrl(final String url) throws ParsingException {
* @return a {@link LinkHandler} complete with information
*/
public LinkHandler fromUrl(final String url, final String baseUrl) throws ParsingException {
if (url == null) {
throw new IllegalArgumentException("URL cannot be null");
}
Objects.requireNonNull(url, "URL cannot be null");
if (!acceptUrl(url)) {
throw new ParsingException("URL not accepted: " + url);
}
Expand All @@ -84,17 +84,13 @@ public LinkHandler fromUrl(final String url, final String baseUrl) throws Parsin
}

public LinkHandler fromId(final String id) throws ParsingException {
if (id == null) {
throw new IllegalArgumentException("id can not be null");
}
Objects.requireNonNull(id, "ID cannot be null");
final String url = getUrl(id);
return new LinkHandler(url, url, id);
}

public LinkHandler fromId(final String id, final String baseUrl) throws ParsingException {
if (id == null) {
throw new IllegalArgumentException("id can not be null");
}
Objects.requireNonNull(id, "ID cannot be null");
final String url = getUrl(id, baseUrl);
return new LinkHandler(url, url, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {

Expand Down Expand Up @@ -35,10 +36,7 @@ public ListLinkHandler fromUrl(final String url) throws ParsingException {

@Override
public ListLinkHandler fromUrl(final String url, final String baseUrl) throws ParsingException {
if (url == null) {
throw new IllegalArgumentException("url may not be null");
}

Objects.requireNonNull(url, "URL may not be null");
return new ListLinkHandler(super.fromUrl(url, baseUrl));
}

Expand Down