Skip to content

Commit

Permalink
Add @nullable annotations to Response (#325)
Browse files Browse the repository at this point in the history
* Add @nullable annotations to Response

* Update javadoc
  • Loading branch information
justin-morey authored Mar 26, 2020
1 parent 8a3a7ba commit d41f34a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 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) {
return new Response<>(result, cacheEntry);
}

Expand All @@ -51,14 +53,14 @@ public static <T> Response<T> error(VolleyError error) {
return new Response<>(error);
}

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

/** Cache metadata for this response, or null in the case of error. */
public final Cache.Entry cacheEntry;
/** Cache metadata for this response; null if not cached or in the case of error. */
@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

0 comments on commit d41f34a

Please sign in to comment.