/** * Set the protocol portion of the location (ex. http). * * @param protocol the protocol */ public UrlBuilder setProtocol(String protocol) { assertNotNull(protocol, "Protocol cannot be null"); if (protocol.endsWith("://")) { protocol = protocol.substring(0, protocol.length() - 3); } else if (protocol.endsWith(":/")) { protocol = protocol.substring(0, protocol.length() - 2); } else if (protocol.endsWith(":")) { protocol = protocol.substring(0, protocol.length() - 1); } if (protocol.contains(":")) { throw new IllegalArgumentException("Invalid protocol: " + protocol); } assertNotNullOrEmpty(protocol, "Protocol cannot be empty", false); this.protocol = protocol; return this; }
/** * <p> * Set a query parameter to a list of values. Each value in the list will be * added as its own key/value pair. * * <p> * <h3>Example Output</h3> * <code>?mykey=value0&mykey=value1&mykey=value2</code> * </p> * * @param key the key * @param values the list of values */ public UrlBuilder setParameter(String key, String... values) { assertNotNullOrEmpty(key, "Key cannot be null or empty", false); assertNotNull(values, "Values cannot null. Try using removeParameter instead."); if (values.length == 0) { throw new IllegalArgumentException( "Values cannot be empty. Try using removeParameter instead."); } listParamMap.put(key, values); return this; }
/** * Set the protocol portion of the location (ex. http). * * @param protocol the protocol */ public UrlBuilder setProtocol(String protocol) { assertNotNull(protocol, "Protocol cannot be null"); if (protocol.endsWith("://")) { protocol = protocol.substring(0, protocol.length() - 3); } else if (protocol.endsWith(":/")) { protocol = protocol.substring(0, protocol.length() - 2); } else if (protocol.endsWith(":")) { protocol = protocol.substring(0, protocol.length() - 1); } if (protocol.contains(":")) { throw new IllegalArgumentException("Invalid protocol: " + protocol); } assertNotNullOrEmpty(protocol, "Protocol cannot be empty", false); this.protocol = protocol; return this; }
/** * Set the protocol portion of the location (ex. http). * * @param protocol the protocol */ public UrlBuilder setProtocol(String protocol) { assertNotNull(protocol, "Protocol cannot be null"); if (protocol.endsWith("://")) { protocol = protocol.substring(0, protocol.length() - 3); } else if (protocol.endsWith(":/")) { protocol = protocol.substring(0, protocol.length() - 2); } else if (protocol.endsWith(":")) { protocol = protocol.substring(0, protocol.length() - 1); } if (protocol.contains(":")) { throw new IllegalArgumentException("Invalid protocol: " + protocol); } assertNotNullOrEmpty(protocol, "Protocol cannot be empty", false); this.protocol = protocol; return this; }
/** * <p> * Set a query parameter to a list of values. Each value in the list will be * added as its own key/value pair. * * <p> * <h3>Example Output</h3> * <code>?mykey=value0&mykey=value1&mykey=value2</code> * </p> * * @param key the key * @param values the list of values */ public UrlBuilder setParameter(String key, String... values) { assertNotNullOrEmpty(key, "Key cannot be null or empty", false); assertNotNull(values, "Values cannot null. Try using removeParameter instead."); if (values.length == 0) { throw new IllegalArgumentException( "Values cannot be empty. Try using removeParameter instead."); } listParamMap.put(key, values); return this; }
/** * <p> * Set a query parameter to a list of values. Each value in the list will be * added as its own key/value pair. * * <p> * <h3>Example Output</h3> * <code>?mykey=value0&mykey=value1&mykey=value2</code> * </p> * * @param key the key * @param values the list of values */ public UrlBuilder setParameter(String key, String... values) { assertNotNullOrEmpty(key, "Key cannot be null or empty", false); assertNotNull(values, "Values cannot null. Try using removeParameter instead."); if (values.length == 0) { throw new IllegalArgumentException( "Values cannot be empty. Try using removeParameter instead."); } listParamMap.put(key, values); return this; }