File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed
guava/src/main/java/retrofit2/adapter/guava
java8/src/main/java/retrofit2/adapter/java8
rxjava/src/main/java/retrofit2/adapter/rxjava Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import com .google .common .util .concurrent .AbstractFuture ;
19
19
import com .google .common .util .concurrent .ListenableFuture ;
20
+ import java .io .IOException ;
20
21
import java .lang .annotation .Annotation ;
21
22
import java .lang .reflect .ParameterizedType ;
22
23
import java .lang .reflect .Type ;
26
27
import retrofit2 .Response ;
27
28
import retrofit2 .Retrofit ;
28
29
30
+ /**
31
+ * A {@linkplain CallAdapter.Factory call adapter} which creates Guava futures.
32
+ * <p>
33
+ * Adding this class to {@link Retrofit} allows you to return {@link ListenableFuture} from service
34
+ * methods.
35
+ * <pre>{@code
36
+ * interface MyService {
37
+ * @GET("user/me")
38
+ * ListenableFuture<User> getUser()
39
+ * }
40
+ * }</pre>
41
+ * There are two configurations supported for the {@code ListenableFuture} type parameter:
42
+ * <ul>
43
+ * <li>Direct body (e.g., {@code ListenableFuture<User>}) returns the deserialized body for 2XX
44
+ * responses, sets {@link HttpException} errors for non-2XX responses, and sets {@link IOException}
45
+ * for network errors.</li>
46
+ * <li>Response wrapped body (e.g., {@code ListenableFuture<Response<User>>}) returns a
47
+ * {@link Response} object for all HTTP responses and sets {@link IOException} for network
48
+ * errors</li>
49
+ * </ul>
50
+ */
29
51
public final class GuavaCallAdapterFactory extends CallAdapter .Factory {
30
52
public static GuavaCallAdapterFactory create () {
31
53
return new GuavaCallAdapterFactory ();
Original file line number Diff line number Diff line change 15
15
*/
16
16
package retrofit2 .adapter .java8 ;
17
17
18
+ import java .io .IOException ;
18
19
import java .lang .annotation .Annotation ;
19
20
import java .lang .reflect .ParameterizedType ;
20
21
import java .lang .reflect .Type ;
25
26
import retrofit2 .Response ;
26
27
import retrofit2 .Retrofit ;
27
28
29
+ /**
30
+ * A {@linkplain CallAdapter.Factory call adapter} which creates Java 8 futures.
31
+ * <p>
32
+ * Adding this class to {@link Retrofit} allows you to return {@link CompletableFuture} from
33
+ * service methods.
34
+ * <pre>{@code
35
+ * interface MyService {
36
+ * @GET("user/me")
37
+ * CompletableFuture<User> getUser()
38
+ * }
39
+ * }</pre>
40
+ * There are two configurations supported for the {@code CompletableFuture} type parameter:
41
+ * <ul>
42
+ * <li>Direct body (e.g., {@code CompletableFuture<User>}) returns the deserialized body for 2XX
43
+ * responses, sets {@link HttpException} errors for non-2XX responses, and sets {@link IOException}
44
+ * for network errors.</li>
45
+ * <li>Response wrapped body (e.g., {@code CompletableFuture<Response<User>>}) returns a
46
+ * {@link Response} object for all HTTP responses and sets {@link IOException} for network
47
+ * errors</li>
48
+ * </ul>
49
+ */
28
50
public final class Java8CallAdapterFactory extends CallAdapter .Factory {
29
51
public static Java8CallAdapterFactory create () {
30
52
return new Java8CallAdapterFactory ();
Original file line number Diff line number Diff line change 15
15
*/
16
16
package retrofit2 .adapter .rxjava ;
17
17
18
+ import java .io .IOException ;
18
19
import java .lang .annotation .Annotation ;
19
20
import java .lang .reflect .ParameterizedType ;
20
21
import java .lang .reflect .Type ;
43
44
* Observable<User> getUser()
44
45
* }
45
46
* }</pre>
47
+ * There are three configurations supported for the {@code Observable} type parameter:
48
+ * <ul>
49
+ * <li>Direct body (e.g., {@code Observable<User>}) calls {@code onNext} with the deserialized body
50
+ * for 2XX responses and calls {@code onError} with {@link HttpException} for non-2XX responses and
51
+ * {@link IOException} for network errors.</li>
52
+ * <li>Response wrapped body (e.g., {@code Observable<Response<User>>}) calls {@code onNext}
53
+ * with a {@link Response} object for all HTTP responses and calls {@code onError} with
54
+ * {@link IOException} for network errors</li>
55
+ * <li>Result wrapped body (e.g., {@code Observable<Result<User>>}) calls {@code onNext} with a
56
+ * {@link Result} object for all HTTP responses and errors.</li>
57
+ * </ul>
46
58
*/
47
59
public final class RxJavaCallAdapterFactory extends CallAdapter .Factory {
48
60
/**
You can’t perform that action at this time.
0 commit comments