Class JacksonBodyAdapter

  • All Implemented Interfaces:
    BodyAdapter

    public class JacksonBodyAdapter
    extends Object
    implements BodyAdapter
    Jackson BodyAdapter to read and write beans as JSON.
    
    
       HttpClientContext.newBuilder()
           .baseUrl(baseUrl)
           .bodyAdapter(new JacksonBodyAdapter())
           .build();
    
     
    • Constructor Detail

      • 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 Detail

      • beanWriter

        public <T> BodyWriter<T> beanWriter​(Class<?> cls)
        Description copied from interface: BodyAdapter
        Return a BodyWriter to write beans of this type as request content.
        Specified by:
        beanWriter in interface BodyAdapter
        Parameters:
        cls - The type of the bean this writer is for
      • beanReader

        public <T> BodyReader<T> beanReader​(Class<T> cls)
        Description copied from interface: BodyAdapter
        Return a BodyReader to read response content and convert to a bean.
        Specified by:
        beanReader in interface BodyAdapter
        Parameters:
        cls - The bean type to convert the content to.
      • listReader

        public <T> BodyReader<List<T>> listReader​(Class<T> cls)
        Description copied from interface: BodyAdapter
        Return a BodyReader to read response content and convert to a list of beans.
        Specified by:
        listReader in interface BodyAdapter
        Parameters:
        cls - The bean type to convert the content to.