killbill-aplcache

jaxrs: Code review integration (currency definition in jaxrs

3/20/2016 6:45:31 PM

Details

diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
index 577e84c..3e29ba3 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
@@ -42,12 +42,12 @@ public class CreditJson extends JsonBase {
     @ApiModelProperty(dataType = "java.util.UUID", required = true)
     private final String accountId;
     private final String description;
-    private final Currency currency;
+    private final String currency;
 
 
     @JsonCreator
     public CreditJson(@JsonProperty("creditAmount") final BigDecimal creditAmount,
-                      @JsonProperty("currency") final Currency currency,
+                      @JsonProperty("currency") final String currency,
                       @JsonProperty("invoiceId") final String invoiceId,
                       @JsonProperty("invoiceNumber") final String invoiceNumber,
                       @JsonProperty("effectiveDate") final LocalDate effectiveDate,
@@ -68,7 +68,7 @@ public class CreditJson extends JsonBase {
         super(toAuditLogJson(auditLogs));
         this.accountId = toString(credit.getAccountId());
         this.creditAmount = credit.getAmount();
-        this.currency = credit.getCurrency();
+        this.currency = credit.getCurrency().name();
         this.invoiceId = toString(credit.getInvoiceId());
         this.invoiceNumber = invoice.getInvoiceNumber().toString();
         this.effectiveDate = credit.getStartDate();
@@ -103,7 +103,7 @@ public class CreditJson extends JsonBase {
         return description;
     }
 
-    public Currency getCurrency() {
+    public String getCurrency() {
         return currency;
     }
 
@@ -137,7 +137,7 @@ public class CreditJson extends JsonBase {
               (creditAmount != null && that.creditAmount != null && creditAmount.compareTo(that.creditAmount) == 0))) {
             return false;
         }
-        if (currency != that.currency) {
+        if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
             return false;
         }
         if (invoiceId != null ? !invoiceId.equals(that.invoiceId) : that.invoiceId != null) {
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java
index a476a22..9c0da34 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/InvoiceItemJson.java
@@ -55,7 +55,7 @@ public class InvoiceItemJson extends JsonBase {
     private final LocalDate startDate;
     private final LocalDate endDate;
     private final BigDecimal amount;
-    private final Currency currency;
+    private final String currency;
 
     @JsonCreator
     public InvoiceItemJson(@JsonProperty("invoiceItemId") final String invoiceItemId,
@@ -72,7 +72,7 @@ public class InvoiceItemJson extends JsonBase {
                            @JsonProperty("startDate") final LocalDate startDate,
                            @JsonProperty("endDate") final LocalDate endDate,
                            @JsonProperty("amount") final BigDecimal amount,
-                           @JsonProperty("currency") final Currency currency,
+                           @JsonProperty("currency") final String currency,
                            @JsonProperty("auditLogs") @Nullable final List<AuditLogJson> auditLogs) {
         super(auditLogs);
         this.invoiceItemId = invoiceItemId;
@@ -97,7 +97,7 @@ public class InvoiceItemJson extends JsonBase {
              toString(item.getAccountId()), toString(item.getBundleId()), toString(item.getSubscriptionId()),
              item.getPlanName(), item.getPhaseName(), item.getUsageName(), item.getInvoiceItemType().toString(),
              item.getDescription(), item.getStartDate(), item.getEndDate(),
-             item.getAmount(), item.getCurrency(), toAuditLogJson(auditLogs));
+             item.getAmount(), item.getCurrency().name(), toAuditLogJson(auditLogs));
     }
 
     public InvoiceItem toInvoiceItem() {
@@ -134,7 +134,7 @@ public class InvoiceItemJson extends JsonBase {
 
             @Override
             public Currency getCurrency() {
-                return currency;
+                return Currency.valueOf(currency);
             }
 
             @Override
@@ -259,7 +259,7 @@ public class InvoiceItemJson extends JsonBase {
         return amount;
     }
 
-    public Currency getCurrency() {
+    public String getCurrency() {
         return currency;
     }
 
@@ -306,7 +306,7 @@ public class InvoiceItemJson extends JsonBase {
         if (bundleId != null ? !bundleId.equals(that.bundleId) : that.bundleId != null) {
             return false;
         }
-        if (currency != that.currency) {
+        if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
             return false;
         }
         if (description != null ? !description.equals(that.description) : that.description != null) {