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
ConstructorsConstructorDescriptionCreate 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, waitMethods 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:BodyAdapterReturn a BodyWriter to write beans of this type as request content.- Specified by:
beanWriterin interfaceBodyAdapter- Parameters:
cls- The type of the bean this writer is for
-
beanReader
Description copied from interface:BodyAdapterReturn a BodyReader to read response content and convert to a bean.- Specified by:
beanReaderin interfaceBodyAdapter- Parameters:
cls- The bean type to convert the content to.
-
listReader
Description copied from interface:BodyAdapterReturn a BodyReader to read response content and convert to a list of beans.- Specified by:
listReaderin interfaceBodyAdapter- Parameters:
cls- The bean type to convert the content to.
-