Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @Nullable annotations to Response #325

Merged
merged 2 commits into from
Mar 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/main/java/com/android/volley/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.android.volley;

import androidx.annotation.Nullable;

/**
* Encapsulates a parsed response for delivery.
*
Expand All @@ -39,7 +41,7 @@ public interface ErrorListener {
}

/** Returns a successful response containing the parsed result. */
public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
public static <T> Response<T> success(@Nullable T result, @Nullable Cache.Entry cacheEntry) {
justin-morey marked this conversation as resolved.
Show resolved Hide resolved
return new Response<>(result, cacheEntry);
}

Expand All @@ -52,13 +54,13 @@ public static <T> Response<T> error(VolleyError error) {
}

/** Parsed response, or null in the case of error. */
public final T result;
@Nullable public final T result;

/** Cache metadata for this response, or null in the case of error. */
public final Cache.Entry cacheEntry;
@Nullable public final Cache.Entry cacheEntry;

/** Detailed error information if <code>errorCode != OK</code>. */
public final VolleyError error;
@Nullable public final VolleyError error;

/** True if this response was a soft-expired one and a second one MAY be coming. */
public boolean intermediate = false;
Expand All @@ -68,7 +70,7 @@ public boolean isSuccess() {
return error == null;
}

private Response(T result, Cache.Entry cacheEntry) {
private Response(@Nullable T result, @Nullable Cache.Entry cacheEntry) {
this.result = result;
this.cacheEntry = cacheEntry;
this.error = null;
Expand Down