Class JsonbBodyAdapter

java.lang.Object
io.avaje.http.client.JsonbBodyAdapter
All Implemented Interfaces:
BodyAdapter

public final class JsonbBodyAdapter extends Object implements BodyAdapter
Avaje Jsonb BodyAdapter to read and write beans as JSON.


   HttpClient.builder()
       .baseUrl(baseUrl)
       .bodyAdapter(new JsonbBodyAdapter())
       .build();

 
  • Constructor Details

    • JsonbBodyAdapter

      public JsonbBodyAdapter(io.avaje.jsonb.Jsonb jsonb)
      Create passing the Jsonb to use.
    • JsonbBodyAdapter

      public JsonbBodyAdapter()
      Create with a default Jsonb that allows unknown properties.
  • Method Details

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

      public <T> BodyWriter<T> beanWriter(Type type)
      Description copied from interface: BodyAdapter
      Return a BodyWriter to write beans of this type as request content.
      Specified by:
      beanWriter in interface BodyAdapter
      Parameters:
      type - 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.
    • beanReader

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

      public <T> BodyReader<List<T>> listReader(Type type)
      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:
      type - 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.