declaring nested generic in java

32 Views Asked by At

I have an ApiResponse generic class with type parameter T like this

public class ApiResponse<T extends Parcelable> {

    ...
    @SerializedName("result")
    private T result;
    ...

}

and I have another class ApiCallback like this


public abstract class ApiCallback<T>  {
     private T result; // in the example is refered to ApiResponse<UserMessage> but i want to access UserMessage
}

and this is the code im calling the classes

new ApiCallback<ApiResponse<UserMessage>>() {
                    @Override
                    protected void onSuccess(Call<ApiResponse<UserMessage>> call, Response<ApiResponse<UserMessage>> response) {
                        UserMessage result = response.body().getResult();

                    }

                    @Override
                    protected void onError(Call<ApiResponse<UserMessage>> call, Response<ApiResponse<UserMessage>> response) {

                    }
                }

question

the T parameter in the ApiCallback is refered to the ApiResponse<UserMessage> how can i access the inner type parameter the UserMessage ?

thanks in advance

0

There are 0 best solutions below