私のコードには、APIからデータを取得する方法があります。RetrofitのonResponseメソッドで@ NonNullを使用してNull Safetyに適していますか?
public void getInitResponse() {
apiService.getInitResponse().enqueue(new Callback<InitGet>() {
@Override
public void onResponse(@NonNull Call<InitGet> call, @NonNull Response<InitGet> response) {
if (response.isSuccessful()) {
String aesKeyEncrypted = response.body().getAsKy();
String aesIvEncrypted = response.body().getAsIv();
}
}
}
getAsKyまたはgetAsIvメソッドはnullを返すことができます。この場合、@NonNull Call<InitGet> call
を使用してよい解決策ですか?または、if-elseを使用してNULLポインタ例外を取得しないで単純なヌルチェックを行う必要がありますか?