@Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeMap() { BindMapToHeadersWithPrefix binder = new BindMapToHeadersWithPrefix("prefix:"); HttpRequest request = HttpRequest.builder().method("POST").endpoint("http: binder.bindToRequest(request, new File("foo")); }
@SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map<?, ?>, "this binder is only valid for Maps!"); checkNotNull(request, "request"); Map<String, String> userMetadata = Maps2.transformKeys((Map<String, String>) input, fn); return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(userMetadata)).build(); }
BindMapToHeadersWithPrefix implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map<?, ?>, "this binder is only valid for Maps!"); checkNotNull(request, "request"); Map<String, String> userMetadata = Maps2.transformKeys((Map<String, String>) input, fn); return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(userMetadata)).build(); } }
BindMapToHeadersWithPrefix implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map<?, ?>, "this binder is only valid for Maps!"); checkNotNull(request, "request"); Map<String, String> userMetadata = Maps2.transformKeys((Map<String, String>) input, fn); return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(userMetadata)).build(); } @Inject  BindMapToHeadersWithPrefix(@Named(PROPERTY_USER_METADATA_PREFIX) final String metadataPrefix); }
BindMapToHeadersWithPrefix implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map<?, ?>, "this binder is only valid for Maps!"); checkNotNull(request, "request"); Map<String, String> userMetadata = Maps2.transformKeys((Map<String, String>) input, fn); return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(userMetadata)).build(); } @Inject  BindMapToHeadersWithPrefix(@Named(PROPERTY_USER_METADATA_PREFIX) final String metadataPrefix); @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input); }
BindMapToHeadersWithPrefix implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map<?, ?>, "this binder is only valid for Maps!"); checkNotNull(request, "request"); Map<String, String> userMetadata = Maps2.transformKeys((Map<String, String>) input, fn); return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(userMetadata)).build(); } @Inject  BindMapToHeadersWithPrefix(@Named(PROPERTY_USER_METADATA_PREFIX) final String metadataPrefix); @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input);  }