package com.debortoliwines.odoo.api;

public class Response {

	private boolean isSuccessful;
	private Exception errorCause;
	private Object responseObject;

	public Response(Exception errorCause) {
		this.isSuccessful = false;
		this.errorCause = errorCause;
		this.responseObject = null;
	}

	public Response(Object responseObject) {
		this.isSuccessful = true;
		this.errorCause = null;
		this.responseObject = responseObject;
	}

	public boolean isSuccessful() {
		return isSuccessful;
	}

	public Throwable getErrorCause() {
		return errorCause;
	}

	public Object getResponseObject() {
		return responseObject;
	}

	public Object[] getResponseObjectAsArray() {
		if (responseObject instanceof Object[]) {
			return (Object[]) responseObject;
		} else {
			return new Object[] { responseObject };
		}
	}
}

@@ -65,16 +65,22 @@
 private 
+final 
 boolean 
@@ -102,16 +102,22 @@
 private 
+final 
 Exceptio
@@ -139,16 +139,22 @@
 private 
+final 
 Object r
@@ -167,16 +167,63 @@
 eObject;
+%0A%09private final Object%5B%5D responseObjectAsArray;
 %0A%0A%09publi
@@ -233,16 +233,22 @@
 esponse(
+final 
 Exceptio
@@ -354,16 +354,62 @@
 = null;%0A
+%09%09this.responseObjectAsArray = new Object%5B0%5D;%0A
 %09%7D%0A%0A%09pub
@@ -421,16 +421,22 @@
 esponse(
+final 
 Object r
@@ -538,32 +538,215 @@
 responseObject;%0A
+%09%09if (responseObject instanceof Object%5B%5D) %7B%0A%09%09%09this.responseObjectAsArray = (Object%5B%5D) responseObject;%0A%09%09%7D else %7B%0A%09%09%09this.responseObjectAsArray = new Object%5B%5D %7B responseObject %7D;%0A%09%09%7D%0A
 %09%7D%0A%0A%09public bool
@@ -972,144 +972,37 @@
 %7B%0A%09%09
-if (responseObject instanceof Object%5B%5D) %7B%0A%09%09%09return (Object%5B%5D) responseObject;%0A%09%09%7D else %7B%0A%09%09%09return new Object%5B%5D %7B responseObject %7D;%0A%09%09%7D
+return responseObjectAsArray;
 %0A%09%7D%0A

Make fields of Response final