java.lang.Object
io.avaje.http.client.JacksonBodyAdapter
- All Implemented Interfaces:
BodyAdapter
Jackson BodyAdapter to read and write beans as JSON.
HttpClient.builder()
.baseUrl(baseUrl)
.bodyAdapter(new JacksonBodyAdapter())
.build();
-
Constructor Summary
ConstructorDescriptionCreate with a ObjectMapper that allows unknown properties and inclusion non empty.JacksonBodyAdapter
(com.fasterxml.jackson.databind.ObjectMapper mapper) Create passing the ObjectMapper to use. -
Method Summary
Modifier and TypeMethodDescription<T> BodyReader
<T> beanReader
(Class<T> cls) Return a BodyReader to read response content and convert to a bean.<T> BodyWriter
<T> beanWriter
(Class<?> cls) Return a BodyWriter to write beans of this type as request content.<T> BodyReader
<List<T>> listReader
(Class<T> cls) Return a BodyReader to read response content and convert to a list of beans.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.avaje.http.client.BodyAdapter
beanReader, beanWriter, listReader
-
Constructor Details
-
JacksonBodyAdapter
public JacksonBodyAdapter(com.fasterxml.jackson.databind.ObjectMapper mapper) Create passing the ObjectMapper to use. -
JacksonBodyAdapter
public JacksonBodyAdapter()Create with a ObjectMapper that allows unknown properties and inclusion non empty.
-
-
Method Details
-
beanWriter
Description copied from interface:BodyAdapter
Return a BodyWriter to write beans of this type as request content.- Specified by:
beanWriter
in interfaceBodyAdapter
- Parameters:
cls
- The type of the bean this writer is for
-
beanReader
Description copied from interface:BodyAdapter
Return a BodyReader to read response content and convert to a bean.- Specified by:
beanReader
in interfaceBodyAdapter
- Parameters:
cls
- The bean type to convert the content to.
-
listReader
Description copied from interface:BodyAdapter
Return a BodyReader to read response content and convert to a list of beans.- Specified by:
listReader
in interfaceBodyAdapter
- Parameters:
cls
- The bean type to convert the content to.
-