OrderRequest.java: add toString()

This commit is contained in:
2018-09-21 11:15:49 -07:00
parent d8bb3f490c
commit 00f2bbf698

View File

@ -9,10 +9,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule; import com.fasterxml.jackson.datatype.joda.JodaModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Base class for order requests to send to the OANDA API. * Base class for order requests to send to the OANDA API.
*/ */
public class OrderRequest { public class OrderRequest {
final Logger log = LoggerFactory.getLogger(OrderRequest.class);
/** /**
* The type of the Order to Create. * The type of the Order to Create.
*/ */
@ -51,4 +56,17 @@ public class OrderRequest {
mapper.setSerializationInclusion(Include.NON_NULL); mapper.setSerializationInclusion(Include.NON_NULL);
return mapper; return mapper;
} }
/**
* Return a better description of the order.
*/
@Override
public String toString() {
try {
return toJSON();
} catch (JsonProcessingException e) {
log.warn("Error converting to JSON", e);
return super.toString();
}
}
} }