aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvan Charlton <evancharlton@gmail.com>2013-06-24 21:18:46 -0700
committerEvan Charlton <evancharlton@gmail.com>2013-06-24 21:18:46 -0700
commite3280b4e47cf6fcc6b4e132baecbd15d7d6f8c19 (patch)
tree2523a6c11fae3649dec12e3bb92c3ba9edac69b9 /src
parent671e1ad59ad7ad16fec7c2690df25ea33aead94f (diff)
downloadvolley-e3280b4e47cf6fcc6b4e132baecbd15d7d6f8c19.tar.gz
Allow method chaining on setters
Return "this" from the setter functions so that the methods can be chained. Change-Id: I5b03f1a9f265af451f5b1807347007569483b580
Diffstat (limited to 'src')
-rw-r--r--src/com/android/volley/Request.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/com/android/volley/Request.java b/src/com/android/volley/Request.java
index 9fee0a0..6462770 100644
--- a/src/com/android/volley/Request.java
+++ b/src/com/android/volley/Request.java
@@ -110,6 +110,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
*
* @deprecated Use {@link #Request(int, String, com.android.volley.Response.ErrorListener)}.
*/
+ @Deprecated
public Request(String url, Response.ErrorListener listener) {
this(Method.DEPRECATED_GET_OR_POST, url, listener);
}
@@ -139,9 +140,12 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Set a tag on this request. Can be used to cancel all requests with this
* tag by {@link RequestQueue#cancelAll(Object)}.
+ *
+ * @return This Request object to allow for chaining.
*/
- public void setTag(Object tag) {
+ public Request<?> setTag(Object tag) {
mTag = tag;
+ return this;
}
/**
@@ -161,9 +165,12 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Sets the retry policy for this request.
+ *
+ * @return This Request object to allow for chaining.
*/
- public void setRetryPolicy(RetryPolicy retryPolicy) {
+ public Request<?> setRetryPolicy(RetryPolicy retryPolicy) {
mRetryPolicy = retryPolicy;
+ return this;
}
/**
@@ -215,16 +222,22 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Associates this request with the given queue. The request queue will be notified when this
* request has finished.
+ *
+ * @return This Request object to allow for chaining.
*/
- public void setRequestQueue(RequestQueue requestQueue) {
+ public Request<?> setRequestQueue(RequestQueue requestQueue) {
mRequestQueue = requestQueue;
+ return this;
}
/**
* Sets the sequence number of this request. Used by {@link RequestQueue}.
+ *
+ * @return This Request object to allow for chaining.
*/
- public final void setSequence(int sequence) {
+ public final Request<?> setSequence(int sequence) {
mSequence = sequence;
+ return this;
}
/**
@@ -254,9 +267,12 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Annotates this request with an entry retrieved for it from cache.
* Used for cache coherency support.
+ *
+ * @return This Request object to allow for chaining.
*/
- public void setCacheEntry(Cache.Entry entry) {
+ public Request<?> setCacheEntry(Cache.Entry entry) {
mCacheEntry = entry;
+ return this;
}
/**
@@ -301,6 +317,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
*
* @deprecated Use {@link #getParams()} instead.
*/
+ @Deprecated
protected Map<String, String> getPostParams() throws AuthFailureError {
return getParams();
}
@@ -319,6 +336,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
*
* @deprecated Use {@link #getParamsEncoding()} instead.
*/
+ @Deprecated
protected String getPostParamsEncoding() {
return getParamsEncoding();
}
@@ -326,6 +344,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* @deprecated Use {@link #getBodyContentType()} instead.
*/
+ @Deprecated
public String getPostBodyContentType() {
return getBodyContentType();
}
@@ -337,6 +356,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
*
* @deprecated Use {@link #getBody()} instead.
*/
+ @Deprecated
public byte[] getPostBody() throws AuthFailureError {
// Note: For compatibility with legacy clients of volley, this implementation must remain
// here instead of simply calling the getBody() function because this function must
@@ -414,9 +434,12 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Set whether or not responses to this request should be cached.
+ *
+ * @return This Request object to allow for chaining.
*/
- public final void setShouldCache(boolean shouldCache) {
+ public final Request<?> setShouldCache(boolean shouldCache) {
mShouldCache = shouldCache;
+ return this;
}
/**