// Path: http/src/main/java/org/ithot/android/transmit/http/Req.java
// static IHTTPHook ihttpHook;
// 
// Path: http/src/main/java/org/ithot/android/transmit/http/Req.java
// public static JSONSerializer json() {
//     return _json;
// }


import android.content.Context;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import cz.msebera.android.httpclient.Header;
import static org.ithot.android.transmit.http.Req.ihttpHook;
import static org.ithot.android.transmit.http.Req.json;
package org.ithot.android.transmit.http;





/**
 * 响应
 */

public abstract class Res<T> implements IHTTPResult {

    public abstract void ok(Header[] headers, T response);

    public abstract void no(Header[] headers, String error);

    private Type getType() {
        Type type = getClass().getGenericSuperclass();
        ParameterizedType parameter = (ParameterizedType) type;
        return parameter.getActualTypeArguments()[0];
    }

    @Override
    public void cache(String response) {
        Type type;
        try {
            type = getType();
        } catch (Exception e) {
            type = null;
        }
        if (type != null && type == String.class) {
            ok(null, (T) response);
            return;
        }
// Path: http/src/main/java/org/ithot/android/transmit/http/Req.java
// static IHTTPHook ihttpHook;
// 
// Path: http/src/main/java/org/ithot/android/transmit/http/Req.java
// public static JSONSerializer json() {
//     return _json;
// }


// Path: http/src/main/java/org/ithot/android/transmit/http/Res.java
import android.content.Context;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import cz.msebera.android.httpclient.Header;
import static org.ithot.android.transmit.http.Req.ihttpHook;
import static org.ithot.android.transmit.http.Req.json;

package org.ithot.android.transmit.http;





/**
 * 响应
 */

public abstract class Res<T> implements IHTTPResult {

    public abstract void ok(Header[] headers, T response);

    public abstract void no(Header[] headers, String error);

    private Type getType() {
        Type type = getClass().getGenericSuperclass();
        ParameterizedType parameter = (ParameterizedType) type;
        return parameter.getActualTypeArguments()[0];
    }

    @Override
    public void cache(String response) {
        Type type;
        try {
            type = getType();
        } catch (Exception e) {
            type = null;
        }
        if (type != null && type == String.class) {
            ok(null, (T) response);
            return;
        }
        T t = (T) json().parse(response, type);