MCPcopy Index your code
hub / github.com/OpenFeign/feign / PojoWriter

Class PojoWriter

form/src/main/java/feign/form/multipart/PojoWriter.java:32–65  ·  view source on GitHub ↗

A custom user's POJO writer. @author Artem Labazin

Source from the content-addressed store, hash-verified

30 * @author Artem Labazin
31 */
32@RequiredArgsConstructor
33@FieldDefaults(level = PRIVATE, makeFinal = true)
34public class PojoWriter extends AbstractWriter {
35
36 Iterable<Writer> writers;
37
38 @Override
39 public boolean isApplicable(Object object) {
40 return isUserPojo(object);
41 }
42
43 @Override
44 public void write(Output output, String boundary, String key, Object object)
45 throws EncodeException {
46 val map = toMap(object);
47 for (val entry : map.entrySet()) {
48 val writer = findApplicableWriter(entry.getValue());
49 if (writer == null) {
50 continue;
51 }
52
53 writer.write(output, boundary, entry.getKey(), entry.getValue());
54 }
55 }
56
57 private Writer findApplicableWriter(Object value) {
58 for (val writer : writers) {
59 if (writer.isApplicable(value)) {
60 return writer;
61 }
62 }
63 return null;
64 }
65}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected