Throw IllegalArgumentException when url is null in LinkHandlerFactory
This commit is contained in:
parent
39de55dcd3
commit
7943130307
|
@ -34,7 +34,7 @@ public abstract class LinkHandlerFactory {
|
|||
public abstract String getUrl(String id) throws ParsingException;
|
||||
public abstract boolean onAcceptUrl(final String url) throws ParsingException;
|
||||
|
||||
public String getUrl(String id, String baseUrl) throws ParsingException{
|
||||
public String getUrl(String id, String baseUrl) throws ParsingException {
|
||||
return getUrl(id);
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,14 @@ public abstract class LinkHandlerFactory {
|
|||
///////////////////////////////////
|
||||
|
||||
public LinkHandler fromUrl(String url) throws ParsingException {
|
||||
if (url == null) throw new IllegalArgumentException("url can not be null");
|
||||
final String baseUrl = Utils.getBaseUrl(url);
|
||||
return fromUrl(url, baseUrl);
|
||||
}
|
||||
|
||||
public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
|
||||
if(url == null) throw new IllegalArgumentException("url can not be null");
|
||||
if(!acceptUrl(url)) {
|
||||
if (url == null) throw new IllegalArgumentException("url can not be null");
|
||||
if (!acceptUrl(url)) {
|
||||
throw new ParsingException("Malformed unacceptable url: " + url);
|
||||
}
|
||||
|
||||
|
@ -58,13 +59,13 @@ public abstract class LinkHandlerFactory {
|
|||
}
|
||||
|
||||
public LinkHandler fromId(String id) throws ParsingException {
|
||||
if(id == null) throw new IllegalArgumentException("id can not be null");
|
||||
if (id == null) throw new IllegalArgumentException("id can not be null");
|
||||
final String url = getUrl(id);
|
||||
return new LinkHandler(url, url, id);
|
||||
}
|
||||
|
||||
public LinkHandler fromId(String id, String baseUrl) throws ParsingException {
|
||||
if(id == null) throw new IllegalArgumentException("id can not be null");
|
||||
if (id == null) throw new IllegalArgumentException("id can not be null");
|
||||
final String url = getUrl(id, baseUrl);
|
||||
return new LinkHandler(url, url, id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue