Class SynchronousCallAdapterFactory

java.lang.Object
retrofit2.CallAdapter.Factory
com.jaredsburrows.retrofit2.adapter.synchronous.SynchronousCallAdapterFactory

public final class SynchronousCallAdapterFactory extends retrofit2.CallAdapter.Factory
A synchronous CallAdapter.Factory that uses the same thread for both I/O and application-level callbacks.

Adding this class to Retrofit allows you to return direct deserialized type from service methods:


 interface MyService {
   @GET("user/me")
   User getUser()
 }
 
or allows you to return deserialized type wrapped in Response:

 interface MyService {
   @GET("user/me")
   Response<User> getUser()
 }
 
CallAdapter.Factory returns the deserialized body for 2XX responses, sets HttpException errors for non-2XX responses, and for network errors.
  • Method Summary

    Modifier and Type
    Method
    Description
    static retrofit2.CallAdapter.Factory
     
    retrofit2.CallAdapter<?,?>
    get(Type returnType, Annotation[] annotations, retrofit2.Retrofit retrofit)
     

    Methods inherited from class retrofit2.CallAdapter.Factory

    getParameterUpperBound, getRawType

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static retrofit2.CallAdapter.Factory create()
    • get

      @Nullable public retrofit2.CallAdapter<?,?> get(Type returnType, Annotation[] annotations, retrofit2.Retrofit retrofit)
      Specified by:
      get in class retrofit2.CallAdapter.Factory