BindTagsToIndexedFormParams implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkNotNull(input, "tags"); Map<String, String> tagValues; if (input instanceof Iterable) { Builder<String, String> builder = ImmutableMap.<String, String> builder(); for (String key : (Iterable<String>) input) { builder.put(key, ""); } tagValues = builder.build(); } else if (input instanceof Map) { tagValues = Map.class.cast(input); } else { throw new IllegalArgumentException("This binder is only valid for Map<String,String> or Iterable<String>"); } return indexMapToFormValuesWithPrefix(request, "Tag", "Key", "Value", tagValues); }  @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeArray() { HttpRequest request = HttpRequest.builder().method("POST").endpoint("http: binder.bindToRequest(request, new File("foo")); }
@Test(expectedExceptions = NullPointerException.class) public void testNullIsBad() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http: binder.bindToRequest(request, null); }