Class 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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static retrofit2.CallAdapter.Factory create()  
      retrofit2.CallAdapter<?,​?> get​(java.lang.reflect.Type returnType, java.lang.annotation.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 Detail

      • create

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

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