com.duowan.mobile.netroid
Class Response<T>

java.lang.Object
  extended by com.duowan.mobile.netroid.Response<T>
Type Parameters:
T - Parsed type of this response

public class Response<T>
extends java.lang.Object

Encapsulates a parsed response for delivery.


Field Summary
 DiskCache.Entry cacheEntry
          Cache metadata for this response, or null in the case of error.
 NetroidError error
          Detailed error information if errorCode != OK.
 boolean intermediate
          True if this response was a soft-expired one and a second one MAY be coming.
 T result
          Parsed response, or null in the case of error.
 
Method Summary
static
<T> Response<T>
error(NetroidError error)
          Returns a failed response containing the given error code and an optional localized message displayed to the user.
 boolean isSuccess()
          Returns whether this response is considered successful.
static
<T> Response<T>
success(T result, NetworkResponse response)
          Returns a successful response containing the parsed result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

public final T result
Parsed response, or null in the case of error.


cacheEntry

public final DiskCache.Entry cacheEntry
Cache metadata for this response, or null in the case of error.


error

public final NetroidError error
Detailed error information if errorCode != OK.


intermediate

public boolean intermediate
True if this response was a soft-expired one and a second one MAY be coming.

Method Detail

success

public static <T> Response<T> success(T result,
                                      NetworkResponse response)
Returns a successful response containing the parsed result.


error

public static <T> Response<T> error(NetroidError error)
Returns a failed response containing the given error code and an optional localized message displayed to the user.


isSuccess

public boolean isSuccess()
Returns whether this response is considered successful.