killbill-memoizeit

account: update AccountData to return objects, not primitives We

6/25/2012 6:44:22 PM

Details

diff --git a/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java b/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
index 778ab57..aebc643 100644
--- a/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
+++ b/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
@@ -116,8 +116,8 @@ public class DefaultAccount extends EntityBase implements Account {
     }
 
     @Override
-    public int getFirstNameLength() {
-        return firstNameLength;
+    public Integer getFirstNameLength() {
+        return Objects.firstNonNull(firstNameLength, 0);
     }
 
     @Override
@@ -126,7 +126,7 @@ public class DefaultAccount extends EntityBase implements Account {
     }
 
     @Override
-    public int getBillCycleDay() {
+    public Integer getBillCycleDay() {
         return billCycleDay;
     }
 
@@ -181,13 +181,13 @@ public class DefaultAccount extends EntityBase implements Account {
     }
 
     @Override
-    public boolean isMigrated() {
-        return this.isMigrated;
+    public Boolean isMigrated() {
+        return Objects.firstNonNull(this.isMigrated, true);
     }
 
     @Override
-    public boolean isNotifiedForInvoices() {
-        return isNotifiedForInvoices;
+    public Boolean isNotifiedForInvoices() {
+        return Objects.firstNonNull(isNotifiedForInvoices, false);
     }
 
     @Override
diff --git a/account/src/main/java/com/ning/billing/account/api/user/DefaultAccountCreationEvent.java b/account/src/main/java/com/ning/billing/account/api/user/DefaultAccountCreationEvent.java
index 8a6cea7..025ff14 100644
--- a/account/src/main/java/com/ning/billing/account/api/user/DefaultAccountCreationEvent.java
+++ b/account/src/main/java/com/ning/billing/account/api/user/DefaultAccountCreationEvent.java
@@ -120,7 +120,6 @@ public class DefaultAccountCreationEvent implements AccountCreationEvent {
 
 
     public static class DefaultAccountData implements AccountData {
-
         private final String externalKey;
         private final String name;
         private final Integer firstNameLength;
@@ -141,7 +140,6 @@ public class DefaultAccountCreationEvent implements AccountCreationEvent {
         private final boolean isMigrated;
         private final boolean isNotifiedForInvoices;
 
-
         public DefaultAccountData(final Account d) {
             this(d.getExternalKey() != null ? d.getExternalKey() : null,
                  d.getName(),
@@ -217,7 +215,7 @@ public class DefaultAccountCreationEvent implements AccountCreationEvent {
         }
 
         @Override
-        public int getFirstNameLength() {
+        public Integer getFirstNameLength() {
             return firstNameLength;
         }
 
@@ -227,7 +225,7 @@ public class DefaultAccountCreationEvent implements AccountCreationEvent {
         }
 
         @Override
-        public int getBillCycleDay() {
+        public Integer getBillCycleDay() {
             return billCycleDay;
         }
 
@@ -299,13 +297,13 @@ public class DefaultAccountCreationEvent implements AccountCreationEvent {
 
         @Override
         @JsonIgnore
-        public boolean isMigrated() {
+        public Boolean isMigrated() {
             return isMigrated;
         }
 
         @Override
         @JsonIgnore
-        public boolean isNotifiedForInvoices() {
+        public Boolean isNotifiedForInvoices() {
             return isNotifiedForInvoices;
         }
 
diff --git a/account/src/test/java/com/ning/billing/account/api/user/TestDefaultAccountUserApi.java b/account/src/test/java/com/ning/billing/account/api/user/TestDefaultAccountUserApi.java
index 27134fa..5d4657b 100644
--- a/account/src/test/java/com/ning/billing/account/api/user/TestDefaultAccountUserApi.java
+++ b/account/src/test/java/com/ning/billing/account/api/user/TestDefaultAccountUserApi.java
@@ -58,9 +58,9 @@ public class TestDefaultAccountUserApi {
         final String externalKey = UUID.randomUUID().toString();
         final String email = UUID.randomUUID().toString();
         final String name = UUID.randomUUID().toString();
-        final int firstNameLength = Integer.MAX_VALUE;
+        final Integer firstNameLength = Integer.MAX_VALUE;
         final Currency currency = Currency.BRL;
-        final int billCycleDay = Integer.MIN_VALUE;
+        final Integer billCycleDay = Integer.MIN_VALUE;
         final UUID paymentMethodId = UUID.randomUUID();
         final DateTimeZone timeZone = DateTimeZone.UTC;
         final String locale = UUID.randomUUID().toString();
@@ -72,8 +72,8 @@ public class TestDefaultAccountUserApi {
         final String country = UUID.randomUUID().toString();
         final String postalCode = UUID.randomUUID().toString();
         final String phone = UUID.randomUUID().toString();
-        final boolean isMigrated = true;
-        final boolean isNotifiedForInvoices = false;
+        final Boolean isMigrated = true;
+        final Boolean isNotifiedForInvoices = false;
         final AccountData data = new DefaultAccount(id, externalKey, email, name, firstNameLength, currency, billCycleDay,
                                                     paymentMethodId, timeZone, locale, address1, address2, companyName,
                                                     city, stateOrProvince, country, postalCode, phone, isMigrated, isNotifiedForInvoices);
diff --git a/account/src/test/java/com/ning/billing/account/dao/TestAccountDao.java b/account/src/test/java/com/ning/billing/account/dao/TestAccountDao.java
index 54f9302..509a21f 100644
--- a/account/src/test/java/com/ning/billing/account/dao/TestAccountDao.java
+++ b/account/src/test/java/com/ning/billing/account/dao/TestAccountDao.java
@@ -115,7 +115,7 @@ public class TestAccountDao extends AccountDaoTestBase {
         final UUID id = account.getId();
         final String key = account.getExternalKey();
         final String name = account.getName();
-        final int firstNameLength = account.getFirstNameLength();
+        final Integer firstNameLength = account.getFirstNameLength();
 
         accountDao.create(account, context);
 
@@ -198,7 +198,7 @@ public class TestAccountDao extends AccountDaoTestBase {
             }
 
             @Override
-            public int getFirstNameLength() {
+            public Integer getFirstNameLength() {
                 return 4;
             }
 
@@ -213,17 +213,17 @@ public class TestAccountDao extends AccountDaoTestBase {
             }
 
             @Override
-            public boolean isMigrated() {
+            public Boolean isMigrated() {
                 return false;
             }
 
             @Override
-            public boolean isNotifiedForInvoices() {
+            public Boolean isNotifiedForInvoices() {
                 return false;
             }
 
             @Override
-            public int getBillCycleDay() {
+            public Integer getBillCycleDay() {
                 return account.getBillCycleDay();
             }
 
diff --git a/api/src/main/java/com/ning/billing/account/api/AccountData.java b/api/src/main/java/com/ning/billing/account/api/AccountData.java
index fa3e135..055338b 100644
--- a/api/src/main/java/com/ning/billing/account/api/AccountData.java
+++ b/api/src/main/java/com/ning/billing/account/api/AccountData.java
@@ -23,16 +23,15 @@ import org.joda.time.DateTimeZone;
 import com.ning.billing.catalog.api.Currency;
 
 public interface AccountData {
-
     public String getExternalKey();
 
     public String getName();
 
-    public int getFirstNameLength();
+    public Integer getFirstNameLength();
 
     public String getEmail();
 
-    public int getBillCycleDay();
+    public Integer getBillCycleDay();
 
     public Currency getCurrency();
 
@@ -58,7 +57,7 @@ public interface AccountData {
 
     public String getPhone();
 
-    public boolean isMigrated();
+    public Boolean isMigrated();
 
-    public boolean isNotifiedForInvoices();
+    public Boolean isNotifiedForInvoices();
 }
diff --git a/api/src/main/java/com/ning/billing/account/api/DefaultMutableAccountData.java b/api/src/main/java/com/ning/billing/account/api/DefaultMutableAccountData.java
index be83546..566822a 100644
--- a/api/src/main/java/com/ning/billing/account/api/DefaultMutableAccountData.java
+++ b/api/src/main/java/com/ning/billing/account/api/DefaultMutableAccountData.java
@@ -124,7 +124,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
     * @see com.ning.billing.account.api.MutableAccountData#getFirstNameLength()
     */
     @Override
-    public int getFirstNameLength() {
+    public Integer getFirstNameLength() {
         return firstNameLength;
     }
 
@@ -140,7 +140,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
     * @see com.ning.billing.account.api.MutableAccountData#getBillCycleDay()
     */
     @Override
-    public int getBillCycleDay() {
+    public Integer getBillCycleDay() {
         return billCycleDay;
     }
 
@@ -236,7 +236,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
     * @see com.ning.billing.account.api.MutableAccountData#isMigrated()
     */
     @Override
-    public boolean isMigrated() {
+    public Boolean isMigrated() {
         return isMigrated;
     }
 
@@ -244,7 +244,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
     * @see com.ning.billing.account.api.MutableAccountData#getSendInvoiceEmails()
     */
     @Override
-    public boolean isNotifiedForInvoices() {
+    public Boolean isNotifiedForInvoices() {
         return isNotifiedForInvoices;
     }
 
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
index d17b0b2..fbf4a68 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
@@ -307,7 +307,7 @@ public class TestIntegrationBase implements TestListenerStatus {
             }
 
             @Override
-            public int getFirstNameLength() {
+            public Integer getFirstNameLength() {
                 return "firstName".length();
             }
 
@@ -322,12 +322,12 @@ public class TestIntegrationBase implements TestListenerStatus {
             }
 
             @Override
-            public boolean isMigrated() {
+            public Boolean isMigrated() {
                 return false;
             }
 
             @Override
-            public boolean isNotifiedForInvoices() {
+            public Boolean isNotifiedForInvoices() {
                 return false;
             }
 
@@ -337,7 +337,7 @@ public class TestIntegrationBase implements TestListenerStatus {
             }
 
             @Override
-            public int getBillCycleDay() {
+            public Integer getBillCycleDay() {
                 return billingDay;
             }
 
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
index 88d31b3..bfbc817 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
@@ -401,7 +401,7 @@ public abstract class TestApiBase implements TestListenerStatus {
             }
 
             @Override
-            public int getFirstNameLength() {
+            public Integer getFirstNameLength() {
                 return "firstName".length();
             }
 
@@ -416,12 +416,12 @@ public abstract class TestApiBase implements TestListenerStatus {
             }
 
             @Override
-            public boolean isMigrated() {
+            public Boolean isMigrated() {
                 return false;
             }
 
             @Override
-            public boolean isNotifiedForInvoices() {
+            public Boolean isNotifiedForInvoices() {
                 return false;
             }
 
@@ -431,7 +431,7 @@ public abstract class TestApiBase implements TestListenerStatus {
             }
 
             @Override
-            public int getBillCycleDay() {
+            public Integer getBillCycleDay() {
                 return 1;
             }
 
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountJson.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountJson.java
index 107a20f..4af8944 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountJson.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountJson.java
@@ -96,12 +96,12 @@ public class AccountJson extends AccountJsonSimple {
             }
 
             @Override
-            public boolean isMigrated() {
+            public Boolean isMigrated() {
                 return false;
             }
 
             @Override
-            public boolean isNotifiedForInvoices() {
+            public Boolean isNotifiedForInvoices() {
                 return false;
             }
 
@@ -122,7 +122,7 @@ public class AccountJson extends AccountJsonSimple {
             }
 
             @Override
-            public int getFirstNameLength() {
+            public Integer getFirstNameLength() {
                 return length;
             }
 
@@ -157,7 +157,7 @@ public class AccountJson extends AccountJsonSimple {
             }
 
             @Override
-            public int getBillCycleDay() {
+            public Integer getBillCycleDay() {
                 return billCycleDay;
             }
 
diff --git a/junction/src/main/java/com/ning/billing/junction/plumbing/api/BlockingAccount.java b/junction/src/main/java/com/ning/billing/junction/plumbing/api/BlockingAccount.java
index 38820bf..40c713d 100644
--- a/junction/src/main/java/com/ning/billing/junction/plumbing/api/BlockingAccount.java
+++ b/junction/src/main/java/com/ning/billing/junction/plumbing/api/BlockingAccount.java
@@ -52,7 +52,7 @@ public class BlockingAccount implements Account {
     }
 
     @Override
-    public int getFirstNameLength() {
+    public Integer getFirstNameLength() {
         return account.getFirstNameLength();
     }
 
@@ -62,7 +62,7 @@ public class BlockingAccount implements Account {
     }
 
     @Override
-    public int getBillCycleDay() {
+    public Integer getBillCycleDay() {
         return account.getBillCycleDay();
     }
 
@@ -140,12 +140,12 @@ public class BlockingAccount implements Account {
     }
 
     @Override
-    public boolean isMigrated() {
+    public Boolean isMigrated() {
         return account.isMigrated();
     }
 
     @Override
-    public boolean isNotifiedForInvoices() {
+    public Boolean isNotifiedForInvoices() {
         return account.isNotifiedForInvoices();
     }
 
diff --git a/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java b/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java
index f0547e6..acc3555 100644
--- a/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java
+++ b/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java
@@ -188,7 +188,7 @@ public class MockAccountBuilder {
             }
 
             @Override
-            public int getFirstNameLength() {
+            public Integer getFirstNameLength() {
 
                 return firstNameLength;
             }
@@ -200,7 +200,7 @@ public class MockAccountBuilder {
             }
 
             @Override
-            public int getBillCycleDay() {
+            public Integer getBillCycleDay() {
 
                 return billingCycleDay;
             }
@@ -278,13 +278,13 @@ public class MockAccountBuilder {
             }
 
             @Override
-            public boolean isMigrated() {
+            public Boolean isMigrated() {
 
                 return migrated;
             }
 
             @Override
-            public boolean isNotifiedForInvoices() {
+            public Boolean isNotifiedForInvoices() {
 
                 return isNotifiedForInvoices;
             }