]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/json/v1_14/AccountListParser.java
finish support for multiple server APIs when retrieving data
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / json / v1_14 / AccountListParser.java
index f3773a52850d5c354c8a9c163469a80fb27bc7df..1df52924ca397b4fced7fbe73a57a9294e37fd8f 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_14;
 
-import com.fasterxml.jackson.databind.MappingIterator;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectReader;
 
+import net.ktnx.mobileledger.async.SendTransactionTask;
+
 import java.io.IOException;
 import java.io.InputStream;
 
-import static net.ktnx.mobileledger.utils.Logger.debug;
-
-public class AccountListParser {
-
-    private final MappingIterator<ParsedLedgerAccount> iterator;
+public class AccountListParser extends net.ktnx.mobileledger.json.AccountListParser {
 
     public AccountListParser(InputStream input) throws IOException {
         ObjectMapper mapper = new ObjectMapper();
@@ -36,14 +33,8 @@ public class AccountListParser {
 
         iterator = reader.readValues(input);
     }
-    public ParsedLedgerAccount nextAccount() {
-        if (!iterator.hasNext()) return null;
-
-        ParsedLedgerAccount next = iterator.next();
-
-        if (next.getAname().equalsIgnoreCase("root")) return nextAccount();
-
-        debug("accounts", String.format("Got account '%s'", next.getAname()));
-        return next;
+    @Override
+    public SendTransactionTask.API getApiVersion() {
+        return SendTransactionTask.API.v1_14;
     }
 }