]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/json/AccountListParser.java
wrap Log.d calls, skipping them on non-debug builds
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / json / AccountListParser.java
index 4dd2e375ae7ac79e9c66c31feb7afc6b6e978e07..a21fc6166236e2bb6d75813f8ae6d4e0240ba327 100644 (file)
@@ -24,6 +24,8 @@ import com.fasterxml.jackson.databind.ObjectReader;
 import java.io.IOException;
 import java.io.InputStream;
 
+import static net.ktnx.mobileledger.utils.Logger.debug;
+
 public class AccountListParser {
 
     private final MappingIterator<ParsedLedgerAccount> iter;
@@ -35,6 +37,13 @@ public class AccountListParser {
         iter = reader.readValues(input);
     }
     public ParsedLedgerAccount nextAccount() throws IOException {
-        return iter.hasNext() ? iter.next() : null;
+        if (!iter.hasNext()) return null;
+
+        ParsedLedgerAccount next = iter.next();
+
+        if (next.getAname().equalsIgnoreCase("root")) return nextAccount();
+
+        debug("accounts", String.format("Got account '%s'", next.getAname()));
+        return next;
     }
 }