package it.reply.utils.web.ws.rest.apiencoding;

import javax.ws.rs.core.MultivaluedMap;

import org.jboss.resteasy.specimpl.MultivaluedMapImpl;

/**
 * This POJO holds a Rest Message (HttpStatusCode, Headers and Body).
 * @author l.biava
 *
 */
public class RestMessage {

	private MultivaluedMap<String, Object> headers = new MultivaluedMapImpl<String, Object>();
	private Object body;
	private int httpStatusCode;

	public int getHttpStatusCode() {
		return httpStatusCode;
	}

	public void setHttpStatusCode(int httpStatusCode) {
		this.httpStatusCode = httpStatusCode;
	}

	public RestMessage(MultivaluedMap<String, Object> headers, Object body) {
		super();
		this.body = body;
		this.headers = headers;
	}

	public RestMessage(MultivaluedMap<String, Object> headers, Object body,
			int httpStatusCode) {
		super();
		this.headers = headers;
		this.body = body;
		this.httpStatusCode = httpStatusCode;
	}

	public void setHeaders(MultivaluedMap<String, Object> headers) {
		this.headers = headers;
	}

	public Object getBody() {
		return body;
	}

	public void setBody(Object body) {
		this.body = body;
	}

	public MultivaluedMap<String, Object> getHeaders() {
		return headers;
	}

	@Override
	public String toString() {
		return "RestMessage [headers=" + headers + ", body=" + body
				+ ", httpStatusCode=" + httpStatusCode + "]";
	}
	
}

@@ -83,24 +83,70 @@
 luedMap;%0D%0A%0D%0A
+import com.google.common.base.MoreObjects;%0D%0A%0D%0A
 import org.j
@@ -1331,49 +1331,77 @@
 %7B%0D%0A%09
-%09
+  
 return 
-%22RestMessage %5B
+MoreObjects.toStringHelper(this)%0D%0A%09  .add(%22
 headers
-=%22 +
+%22,
  headers
  + %22
@@ -1400,38 +1400,43 @@
 ders
- + %22, body=%22 +
+)%0D%0A%09  .add(%22body%22,
  body
+)
 %0D%0A%09
-%09%09%09+ %22, 
+  .add(%22
 http
@@ -1449,12 +1449,10 @@
 Code
-=%22 +
+%22,
  htt
@@ -1466,14 +1466,20 @@
 Code
- + %22%5D%22
+).toString()
 ;%0D%0A%09

Use nullsafe builder for tostring