BasicRequest { static Collection<String> toEncodedValues(String key, Object val) throws UnsupportedEncodingException { if (val == null) { throw new NullPointerException(key); } if (val instanceof Number || val instanceof String) { return Collections.singleton(urlEncode(val.toString())); } boolean multiValue = key.endsWith("[]"); if (val instanceof Collection) { List<String> ret = new ArrayList<String>(); int i = 0; for (Object o : (Collection) val) { if (o == null) { throw new NullPointerException(key + '[' + i + ']'); } else if (o instanceof Number || o instanceof String) { if (multiValue) { ret.add(urlEncode(o.toString())); } else { ret.add(o.toString()); } } else { throw new IllegalArgumentException(key + '[' + i + "]: " + val.getClass() + "=" + val); } i++; } if (! multiValue) { StringBuilder sb = new StringBuilder(); String join = ""; for (String s : ret) { sb.append(join).append(s); join = ","; } return Collections.singleton(urlEncode(sb.toString())); } return ret; } if (val instanceof Array) { List<String> ret = new ArrayList<String>(); for (int i = 0; i < Array.getLength(val); i++) { Object o = Array.get(val, i); if (o == null) { throw new NullPointerException(key + '[' + i + ']'); } else if (o instanceof Number || o instanceof String) { if (multiValue) { ret.add(urlEncode(o.toString())); } else { ret.add(o.toString()); } } else { throw new IllegalArgumentException(key + '[' + i + "]: " + val.getClass() + "=" + val); } i++; } if (! multiValue) { StringBuilder sb = new StringBuilder(); String join = ""; for (String s : ret) { sb.append(join).append(s); join = ","; } return Collections.singleton(urlEncode(sb.toString())); } return ret; } throw new IllegalArgumentException(key + ": " + val.getClass() + "=" + val); } BasicRequest();   BasicRequest(HttpClientRequester httpClientRequester);   }
@Test void toEncodedValues() { }