@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }) public void testNullIsBad() { BindMapToHeadersWithPrefix binder = new BindMapToHeadersWithPrefix("prefix:"); HttpRequest request = HttpRequest.builder().method("GET").endpoint("http: binder.bindToRequest(request, null); }
@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 Map!"); checkNotNull(request, "request"); Map<Integer, String> map = (Map<Integer, String>) input; checkArgument(!map.isEmpty(), "Please send parts"); StringBuilder content = new StringBuilder(); content.append("<CompleteMultipartUpload>"); for (Entry<Integer, String> entry : map.entrySet()) { content.append("<Part>"); content.append("<PartNumber>").append(entry.getKey()).append("</PartNumber>"); content.append("<ETag>").append(entry.getValue()).append("</ETag>"); content.append("</Part>"); } content.append("</CompleteMultipartUpload>"); Payload payload = Payloads.newStringPayload(content.toString()); payload.getContentMetadata().setContentType(MediaType.TEXT_XML); request.setPayload(payload); return request; }
BindPartIdsAndETagsToRequest 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 Map!"); checkNotNull(request, "request"); Map<Integer, String> map = (Map<Integer, String>) input; checkArgument(!map.isEmpty(), "Please send parts"); StringBuilder content = new StringBuilder(); content.append("<CompleteMultipartUpload>"); for (Entry<Integer, String> entry : map.entrySet()) { content.append("<Part>"); content.append("<PartNumber>").append(entry.getKey()).append("</PartNumber>"); content.append("<ETag>").append(entry.getValue()).append("</ETag>"); content.append("</Part>"); } content.append("</CompleteMultipartUpload>"); Payload payload = Payloads.newStringPayload(content.toString()); payload.getContentMetadata().setContentType(MediaType.TEXT_XML); request.setPayload(payload); return request; } }
BindPartIdsAndETagsToRequest 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 Map!"); checkNotNull(request, "request"); Map<Integer, String> map = (Map<Integer, String>) input; checkArgument(!map.isEmpty(), "Please send parts"); StringBuilder content = new StringBuilder(); content.append("<CompleteMultipartUpload>"); for (Entry<Integer, String> entry : map.entrySet()) { content.append("<Part>"); content.append("<PartNumber>").append(entry.getKey()).append("</PartNumber>"); content.append("<ETag>").append(entry.getValue()).append("</ETag>"); content.append("</Part>"); } content.append("</CompleteMultipartUpload>"); Payload payload = Payloads.newStringPayload(content.toString()); payload.getContentMetadata().setContentType(MediaType.TEXT_XML); request.setPayload(payload); return request; }  }
BindPartIdsAndETagsToRequest 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 Map!"); checkNotNull(request, "request"); Map<Integer, String> map = (Map<Integer, String>) input; checkArgument(!map.isEmpty(), "Please send parts"); StringBuilder content = new StringBuilder(); content.append("<CompleteMultipartUpload>"); for (Entry<Integer, String> entry : map.entrySet()) { content.append("<Part>"); content.append("<PartNumber>").append(entry.getKey()).append("</PartNumber>"); content.append("<ETag>").append(entry.getValue()).append("</ETag>"); content.append("</Part>"); } content.append("</CompleteMultipartUpload>"); Payload payload = Payloads.newStringPayload(content.toString()); payload.getContentMetadata().setContentType(MediaType.TEXT_XML); request.setPayload(payload); return request; }  @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input); }
BindPartIdsAndETagsToRequest 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 Map!"); checkNotNull(request, "request"); Map<Integer, String> map = (Map<Integer, String>) input; checkArgument(!map.isEmpty(), "Please send parts"); StringBuilder content = new StringBuilder(); content.append("<CompleteMultipartUpload>"); for (Entry<Integer, String> entry : map.entrySet()) { content.append("<Part>"); content.append("<PartNumber>").append(entry.getKey()).append("</PartNumber>"); content.append("<ETag>").append(entry.getValue()).append("</ETag>"); content.append("</Part>"); } content.append("</CompleteMultipartUpload>"); Payload payload = Payloads.newStringPayload(content.toString()); payload.getContentMetadata().setContentType(MediaType.TEXT_XML); request.setPayload(payload); return request; }  @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input);  }