]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/json/v1_15/AccountListParser.java
a step towards API-independent JSON parsing of accounts
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / json / v1_15 / AccountListParser.java
index 4206d0fc482429a475fbbb5628c5a834e86a836b..33c554c85b41f0406a5cff7197ce1826a4c94e02 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
 
 package net.ktnx.mobileledger.json.v1_15;
 
-import com.fasterxml.jackson.databind.MappingIterator;
 import com.fasterxml.jackson.databind.ObjectMapper;
 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;
+public class AccountListParser extends net.ktnx.mobileledger.json.AccountListParser {
 
     public AccountListParser(InputStream input) throws IOException {
         ObjectMapper mapper = new ObjectMapper();
         ObjectReader reader = mapper.readerFor(ParsedLedgerAccount.class);
 
-        iter = reader.readValues(input);
-    }
-    public ParsedLedgerAccount nextAccount() {
-        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;
+        iterator = reader.readValues(input);
     }
 }