// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnExceptionListener.java
// public interface OnExceptionListener {
//     void onExceptionThrown(Exception e);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnListResponseListener.java
// public interface OnListResponseListener<T> {
// 
//     void onResponse(int code, List<T> object, Response fullResponse);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnObjResponseListener.java
// public interface OnObjResponseListener<T> {
// 
//     void onResponse(int code, T object, Response fullResponse);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnResponseListener.java
// public interface OnResponseListener {
// 
//     void onResponse(int code, Response fullResponse, Exception e);
// 
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnTimeoutListener.java
// public interface OnTimeoutListener {
//     void onTimeout();
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/AbstractNotifier.java
// public abstract class AbstractNotifier {
// 
//     public abstract void processResponseAndNotify(ResponseImpl response) throws IOException;
// 
// 
// 
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/ListNotifier.java
// public class ListNotifier<T> extends AbstractNotifier{
// 
// 
//     private final Class<T> clazz;
//     private final OnListResponseListener<T> listener;
// 
//     public ListNotifier(Class<T> clazz, OnListResponseListener<T> listener){
//         this.clazz = clazz;
//         this.listener = listener;
//     }
// 
//     @SuppressWarnings("unchecked")
//     @Override
//     public void processResponseAndNotify(ResponseImpl response) throws IOException {
// 
//         Class listClass = Array.newInstance(clazz,0).getClass();
// 
//         T[] array = (T[]) response.deserializeBody(listClass);
// 
//         List<T> list = Arrays.asList(array);
//         listener.onResponse(response.getStatusCode(), list, response);
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/ObjectNotifier.java
// public class ObjectNotifier<T> extends AbstractNotifier{
// 
// 
//     private final Class<T> clazz;
//     private final OnObjResponseListener<T> listener;
// 
//     public ObjectNotifier(Class<T> clazz, OnObjResponseListener<T> listener){
//         this.clazz = clazz;
//         this.listener = listener;
//     }
// 
//     @Override
//     public void processResponseAndNotify(ResponseImpl response) throws IOException {
//         T object = response.deserializeBody(clazz);
//         listener.onResponse(response.getStatusCode(), object, response);
//     }
// 
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/PlainNotifier.java
// public class PlainNotifier extends AbstractNotifier {
// 
//     private final OnResponseListener listener;
// 
//     public PlainNotifier(OnResponseListener listener){
//         this.listener = listener;
//     }
// 
//     @Override
//     public void processResponseAndNotify(ResponseImpl response) {
//         listener.onResponse(response.getStatusCode(), response, null);
//     }
// }


import com.greengrowapps.ggarest.listeners.OnExceptionListener;
import com.greengrowapps.ggarest.listeners.OnListResponseListener;
import com.greengrowapps.ggarest.listeners.OnObjResponseListener;
import com.greengrowapps.ggarest.listeners.OnResponseListener;
import com.greengrowapps.ggarest.listeners.OnTimeoutListener;
import com.greengrowapps.ggarest.notifiers.AbstractNotifier;
import com.greengrowapps.ggarest.notifiers.ListNotifier;
import com.greengrowapps.ggarest.notifiers.ObjectNotifier;
import com.greengrowapps.ggarest.notifiers.PlainNotifier;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
    public void registerListener(int statusCode, OnResponseListener listener){
        PlainNotifier plainNotifier = new PlainNotifier(listener);
        statusCodeListeners.put(statusCode, plainNotifier);
    }
    public <T> void registerListener(Class<T> responseClass, int statusCode, OnObjResponseListener<T> listener){
        ObjectNotifier<T> objectNotifier = new ObjectNotifier<>(responseClass,listener);
        statusCodeListeners.put(statusCode, objectNotifier);
    }
    public <T> void registerListener(Class<T> responseClass, int statusCode, OnListResponseListener<T> listener){
        ListNotifier<T> listNotifier = new ListNotifier<>(responseClass, listener);
        statusCodeListeners.put(statusCode, listNotifier);
    }
    public void setDefaultListener(OnResponseListener defaultListener) {
        this.defaultListener = defaultListener;
    }

    public void setTimeoutListener(OnTimeoutListener timeoutListener) {
        this.timeoutListener = timeoutListener;
    }

    public boolean isPostPut(){
        return method==RestMethod.POST || method==RestMethod.PUT;
    }

    public RestMethod getMethod() {
        return method;
    }
    public boolean hasBody() {
        return body!=null;
    }
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnExceptionListener.java
// public interface OnExceptionListener {
//     void onExceptionThrown(Exception e);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnListResponseListener.java
// public interface OnListResponseListener<T> {
// 
//     void onResponse(int code, List<T> object, Response fullResponse);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnObjResponseListener.java
// public interface OnObjResponseListener<T> {
// 
//     void onResponse(int code, T object, Response fullResponse);
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnResponseListener.java
// public interface OnResponseListener {
// 
//     void onResponse(int code, Response fullResponse, Exception e);
// 
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/listeners/OnTimeoutListener.java
// public interface OnTimeoutListener {
//     void onTimeout();
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/AbstractNotifier.java
// public abstract class AbstractNotifier {
// 
//     public abstract void processResponseAndNotify(ResponseImpl response) throws IOException;
// 
// 
// 
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/ListNotifier.java
// public class ListNotifier<T> extends AbstractNotifier{
// 
// 
//     private final Class<T> clazz;
//     private final OnListResponseListener<T> listener;
// 
//     public ListNotifier(Class<T> clazz, OnListResponseListener<T> listener){
//         this.clazz = clazz;
//         this.listener = listener;
//     }
// 
//     @SuppressWarnings("unchecked")
//     @Override
//     public void processResponseAndNotify(ResponseImpl response) throws IOException {
// 
//         Class listClass = Array.newInstance(clazz,0).getClass();
// 
//         T[] array = (T[]) response.deserializeBody(listClass);
// 
//         List<T> list = Arrays.asList(array);
//         listener.onResponse(response.getStatusCode(), list, response);
//     }
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/ObjectNotifier.java
// public class ObjectNotifier<T> extends AbstractNotifier{
// 
// 
//     private final Class<T> clazz;
//     private final OnObjResponseListener<T> listener;
// 
//     public ObjectNotifier(Class<T> clazz, OnObjResponseListener<T> listener){
//         this.clazz = clazz;
//         this.listener = listener;
//     }
// 
//     @Override
//     public void processResponseAndNotify(ResponseImpl response) throws IOException {
//         T object = response.deserializeBody(clazz);
//         listener.onResponse(response.getStatusCode(), object, response);
//     }
// 
// }
// 
// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/notifiers/PlainNotifier.java
// public class PlainNotifier extends AbstractNotifier {
// 
//     private final OnResponseListener listener;
// 
//     public PlainNotifier(OnResponseListener listener){
//         this.listener = listener;
//     }
// 
//     @Override
//     public void processResponseAndNotify(ResponseImpl response) {
//         listener.onResponse(response.getStatusCode(), response, null);
//     }
// }


// Path: GgaRestJavaLib/ggarest/src/main/java/com/greengrowapps/ggarest/ConnectionDefinition.java
import com.greengrowapps.ggarest.listeners.OnExceptionListener;
import com.greengrowapps.ggarest.listeners.OnListResponseListener;
import com.greengrowapps.ggarest.listeners.OnObjResponseListener;
import com.greengrowapps.ggarest.listeners.OnResponseListener;
import com.greengrowapps.ggarest.listeners.OnTimeoutListener;
import com.greengrowapps.ggarest.notifiers.AbstractNotifier;
import com.greengrowapps.ggarest.notifiers.ListNotifier;
import com.greengrowapps.ggarest.notifiers.ObjectNotifier;
import com.greengrowapps.ggarest.notifiers.PlainNotifier;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

    public void registerListener(int statusCode, OnResponseListener listener){
        PlainNotifier plainNotifier = new PlainNotifier(listener);
        statusCodeListeners.put(statusCode, plainNotifier);
    }
    public <T> void registerListener(Class<T> responseClass, int statusCode, OnObjResponseListener<T> listener){
        ObjectNotifier<T> objectNotifier = new ObjectNotifier<>(responseClass,listener);
        statusCodeListeners.put(statusCode, objectNotifier);
    }
    public <T> void registerListener(Class<T> responseClass, int statusCode, OnListResponseListener<T> listener){
        ListNotifier<T> listNotifier = new ListNotifier<>(responseClass, listener);
        statusCodeListeners.put(statusCode, listNotifier);
    }
    public void setDefaultListener(OnResponseListener defaultListener) {
        this.defaultListener = defaultListener;
    }

    public void setTimeoutListener(OnTimeoutListener timeoutListener) {
        this.timeoutListener = timeoutListener;
    }

    public boolean isPostPut(){
        return method==RestMethod.POST || method==RestMethod.PUT;
    }

    public RestMethod getMethod() {
        return method;
    }
    public boolean hasBody() {
        return body!=null;
    }
    public Object getBody() {