Interface ObjectMapper

All Known Implementing Classes:
GsonObjectMapper, JacksonObjectMapper

public interface ObjectMapper
Interface for object mappers that can transform response bodies to other structures.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    readValue(String value, Class<T> valueType)
    reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.
    default <T> T
    readValue(String value, GenericType<T> genericType)
    reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.
    Takes a object and serialize it as a string.
  • Method Details

    • readValue

      <T> T readValue(String value, Class<T> valueType)
      reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.
      Type Parameters:
      T - the type
      Parameters:
      value - the content as a string.
      valueType - the type to map to
      Returns:
      the object mapped into the class type
    • readValue

      default <T> T readValue(String value, GenericType<T> genericType)
      reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder. This method takes a GenericType which retains Generics information for types lke List<Foo>
      Type Parameters:
      T - the type
      Parameters:
      value - the content as a string.
      genericType - the generic type
      Returns:
      the object mapped into the class type
    • writeValue

      String writeValue(Object value)
      Takes a object and serialize it as a string. This is used to map objects to bodies to pass to requests
      Parameters:
      value - the object to serialize to a string
      Returns:
      the serialized string of the object