Request implements Comparable<Request<T>> { @Override public int compareTo(Request<T> other) { Priority left = this.getPriority(); Priority right = other.getPriority(); return left == right ? this.mSequence - other.mSequence : right.ordinal() - left.ordinal(); } @Deprecated  Request(String url, Response.ErrorListener listener);  Request(int method, String url, Response.ErrorListener listener); void setParams(Map<String, String> params); int getMethod(); Request<?> setTag(Object tag); Object getTag(); Response.ErrorListener getErrorListener(); int getTrafficStatsTag(); Request<?> setRetryPolicy(RetryPolicy retryPolicy); void addMarker(String tag); Request<?> setRequestQueue(RequestQueue requestQueue); final Request<?> setSequence(int sequence); final int getSequence(); String getUrl(); String getCacheKey(); Request<?> setCacheEntry(Cache.Entry entry); Cache.Entry getCacheEntry(); void cancel(); boolean isCanceled(); Map<String, String> getHeaders(); @Deprecated String getPostBodyContentType(); @Deprecated byte[] getPostBody(); String getBodyContentType(); byte[] getBody(); final Request<?> setShouldCache(boolean shouldCache); final boolean shouldCache(); Priority getPriority(); final int getTimeoutMs(); RetryPolicy getRetryPolicy(); void markDelivered(); boolean hasHadResponseDelivered(); void deliverError(VolleyError error); @Override int compareTo(Request<T> other); @Override String toString(); static final String DEFAULT_PARAMS_ENCODING; }
@Test public void compareTo() { int sequence = 0; TestRequest low = new TestRequest(Priority.LOW); low.setSequence(sequence++); TestRequest low2 = new TestRequest(Priority.LOW); low2.setSequence(sequence++); TestRequest high = new TestRequest(Priority.HIGH); high.setSequence(sequence++); TestRequest immediate = new TestRequest(Priority.IMMEDIATE); immediate.setSequence(sequence++); assertTrue(low.compareTo(high) > 0); assertTrue(high.compareTo(low) < 0); assertTrue(low.compareTo(low2) < 0); assertTrue(low.compareTo(immediate) > 0); assertTrue(immediate.compareTo(high) < 0); }