Java Code Examples for com.safframework.tony.common.utils.Preconditions#checkNotNull()

The following examples show how to use com.safframework.tony.common.utils.Preconditions#checkNotNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: URLParser.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
public void updateParams(String name, String... values) {
    Preconditions.checkNotNull(name);
    if (values.length == 0) {
        throw new SpiderException("values should not be empty");
    }
    List<String> list = getOrCreate(params, name);
    list.clear();
    for (String value : values) {
        list.add(encode(value));
    }
}
 
Example 2
Source File: URLParser.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
private String decode(String value) {
    Preconditions.checkNotNull(value);
    try {
        return charset == null ? value : URLDecoder.decode(value, charset);
    } catch (UnsupportedEncodingException e) {
        throw new SpiderException(e);
    }
}
 
Example 3
Source File: URLParser.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
private String encode(String value) {
    Preconditions.checkNotNull(value);
    try {
        return charset == null ? value : URLEncoder.encode(value, charset);
    } catch (UnsupportedEncodingException e) {
        throw new SpiderException(e);
    }
}
 
Example 4
Source File: URLParser.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
private static List<String> getOrCreate(Map<String, List<String>> map, String name) {
    Preconditions.checkNotNull(name);
    List<String> list = map.get(name);
    if (list == null) {
        list = new ArrayList<String>();
        map.put(name, list);
    }
    return list;
}
 
Example 5
Source File: URLParser.java    From NetDiscovery with Apache License 2.0 4 votes vote down vote up
public List<String> getRawParams(String name) {
    Preconditions.checkNotNull(name);
    return this.params.get(name);
}