Interface Converter

  • All Known Implementing Classes:
    GsonConverter


    public interface Converter
    Arbiter for converting objects to and from their representation in HTTP.
    • Method Summary

      Modifier and Type Method and Description
      Object fromBody(TypedInput body, Type type)
      Convert an HTTP response body to a concrete object of the specified type.
      TypedOutput toBody(Object object)
      Convert an object to an appropriate representation for HTTP transport.
    • Method Detail

      • fromBody

        Object fromBody(TypedInput body,
                        Type type)
                 throws ConversionException
        Convert an HTTP response body to a concrete object of the specified type.
        Parameters:
        body - HTTP response body.
        type - Target object type.
        Returns:
        Instance of type which will be cast by the caller.
        Throws:
        ConversionException - if conversion was unable to complete. This will trigger a call to Callback.failure(retrofit.RetrofitError) or throw a RetrofitError. The exception message should report all necessary information about its cause as the response body will be set to null.
      • toBody

        TypedOutput toBody(Object object)
        Convert an object to an appropriate representation for HTTP transport.
        Parameters:
        object - Object instance to convert.
        Returns:
        Representation of the specified object as bytes.