public static ContentResource template(final String template, final String name1, final String value1, final String name2, final String value2) { return template(text(checkNotNullOrEmpty(template, "Template should not be null")), checkNotNullOrEmpty(name1, "Template variable name should not be null"), checkNotNullOrEmpty(value1, "Template variable value should not be null"), checkNotNullOrEmpty(name2, "Template variable name should not be null"), checkNotNullOrEmpty(value2, "Template variable value should not be null")); }
public static MountPredicate include(final String glob) { checkNotNullOrEmpty(glob, "Glob should not be null or empty"); final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + glob); return new MountPredicate() { @Override public boolean apply(final String filename) { return matcher.matches(Paths.get(filename)); } }; }
public static URL toUrl(final String url) { try { return new URL(checkNotNullOrEmpty(url, "URL should not be null")); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } }
public static String checkValidVariableName(final String name) { if (!RESERVED_NAME.contains( checkNotNullOrEmpty(name, "Template variable name should not be null"))) { return name; } throw new IllegalArgumentException("Template variable name should not be same with reserved name"); }
public static HttpsCertificate certificate(final ContentResource resource, final String keyStorePassword, final String certPassword) { return new HttpsCertificate(checkNotNull(resource), checkNotNullOrEmpty(keyStorePassword, "Key store password should not be null"), checkNotNullOrEmpty(certPassword, "Cert password should not be null")); } }
private static File joinFiles(final String path1, final String path2) { checkNotNullOrEmpty(path2, "Empty path is not allowed"); if (path1 == null) { return new File(path2); } return new File(new File(path1), path2); }
public static ContentResource template(final String template, final String name, final String value) { return template(text(checkNotNullOrEmpty(template, "Template should not be null")), checkNotNullOrEmpty(name, "Template variable name should not be null"), checkNotNullOrEmpty(value, "Template variable value should not be null")); }
public static <ExtractorType1, ExtractorType2> ContentResource template(final String template, final String name1, final RequestExtractor<ExtractorType1> extractor1, final String name2, final RequestExtractor<ExtractorType2> extractor2) { return template(text(checkNotNullOrEmpty(template, "Template should not be null")), checkNotNullOrEmpty(name1, "Template variable name should not be null"), checkNotNull(extractor1, "Template variable extractor should not be null"), checkNotNullOrEmpty(name2, "Template variable name should not be null"), checkNotNull(extractor2, "Template variable extractor should not be null")); }
public static ContentResource template(final ContentResource template, final String name1, final String value1, final String name2, final String value2) { return template(checkNotNull(template, "Template should not be null"), checkNotNullOrEmpty(name1, "Template variable name should not be null"), var(checkNotNullOrEmpty(value1, "Template variable value should not be null")), checkNotNullOrEmpty(name2, "Template variable name should not be null"), var(checkNotNullOrEmpty(value2, "Template variable value should not be null"))); }
private static String checkValidUrlItem(final String id, final String item) { checkNotNullOrEmpty(id, item + " should not be null or empty"); if (id.contains(URLs.SEPARATOR)) { throw new IllegalArgumentException(item + " should not contain '/'"); } if (!URLs.isValidUrl(id)) { throw new IllegalArgumentException(item + " should not contains invalid URI character"); } return id; }
public static ResponseHandler cookie(final String key, final String value, final CookieAttribute... attributes) { return cookie(checkNotNullOrEmpty(key, "Cookie key should not be null"), text(checkNotNullOrEmpty(value, "Cookie value should not be null")), checkNotNull(attributes, "Cookie options should not be null")); }
public static <T> ContentResource template(final String template, final String name, final RequestExtractor<T> extractor) { return template(text(checkNotNullOrEmpty(template, "Template should not be null")), checkNotNullOrEmpty(name, "Template variable name should not be null"), checkNotNull(extractor, "Template variable extractor should not be null")); }
public static ContentResource template(final ContentResource template, final String name, final String value) { return template(checkNotNull(template, "Template should not be null"), checkNotNullOrEmpty(name, "Template variable name should not be null"), var(checkNotNullOrEmpty(value, "Template variable value should not be null"))); }
public static ResponseHandler header(final String name, final Resource value) { return new HeaderResponseHandler(checkNotNullOrEmpty(name, "Header name should not be null"), checkNotNull(value, "Header value should not be null")); }
public static RequestExtractor<String[]> header(final String header) { return new HeaderRequestExtractor(checkNotNullOrEmpty(header, "Header name should not be null")); }
public static RequestExtractor<String> cookie(final String key) { return new CookieRequestExtractor(checkNotNullOrEmpty(key, "Cookie key should not be null")); }
public static XPathRequestExtractor xpath(final String xpath) { return new XPathRequestExtractor(checkNotNullOrEmpty(xpath, "XPath should not be null")); }
public static Resource uri(final String uri) { return uriResource(checkNotNullOrEmpty(uri, "URI should not be null")); }
public static JsonPathRequestExtractor jsonPath(final String jsonPath) { return new JsonPathRequestExtractor(checkNotNullOrEmpty(jsonPath, "JsonPath should not be null")); }
public static ProxyConfig.Builder from(final String localBase) { return ProxyConfig.builder(checkNotNullOrEmpty(localBase, "Local base should not be null")); }