【发布时间】:2015-06-19 03:45:04
【问题描述】:
我有一个 API,它为 gson/retrofit 解析的所有请求返回标准回复。
public class ServerReply<T> {
@Expose
private String status;
@Expose
private T data;
@Expose
private String message;
}
我有一个 Retrofit 接口,它将返回 serverReply 中的用户列表。
public interface Test {
@POST("/Test")
void runTest(@Body Body body, Callback<ServerReply<List<User>>> response);
}
我想根据正文的内容获得不同的对象列表。是否可以使用模板/泛型来完成此操作?(见下文)
public interface Test<T> {
@POST("/Test")
void runTest(@Body Body body, Callback<ServerReply<List<T>>> response);
}
【问题讨论】: