]> git.ktnx.net Git - mobile-ledger.git/commitdiff
copy-constructors for TemplateHeader/TemplateAccount/TemplateWithAccounts
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 5 Feb 2021 05:45:21 +0000 (07:45 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 5 Feb 2021 13:14:22 +0000 (13:14 +0000)
app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java
app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java
app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java

index 8651e3fee09ba66ac857788e30a62e0e04894e84..f697b4dd54466431da96c383107f3e68235acf50 100644 (file)
@@ -69,6 +69,20 @@ public class TemplateAccount extends TemplateBase {
         this.templateId = templateId;
         this.position = position;
     }
+    public TemplateAccount(TemplateAccount o) {
+        id = o.id;
+        templateId = o.templateId;
+        accountName = o.accountName;
+        position = o.position;
+        accountNameMatchGroup = o.accountNameMatchGroup;
+        currency = o.currency;
+        currencyMatchGroup = o.currencyMatchGroup;
+        amount = o.amount;
+        amountMatchGroup = o.amountMatchGroup;
+        accountComment = o.accountComment;
+        accountCommentMatchGroup = o.accountCommentMatchGroup;
+        negateAmount = o.negateAmount;
+    }
     public Long getId() {
         return id;
     }
index 5422767f9e74d01ffbedb63059263692da8f66c7..68a11232af671cda89a9dba6439e0897142f3557 100644 (file)
@@ -66,6 +66,22 @@ public class TemplateHeader extends TemplateBase {
         this.name = name;
         this.regularExpression = regularExpression;
     }
+    public TemplateHeader(TemplateHeader origin) {
+        id = origin.id;
+        name = origin.name;
+        regularExpression = origin.regularExpression;
+        testText = origin.testText;
+        transactionDescription = origin.transactionDescription;
+        transactionDescriptionMatchGroup = origin.transactionDescriptionMatchGroup;
+        transactionComment = origin.transactionComment;
+        transactionCommentMatchGroup = origin.transactionCommentMatchGroup;
+        dateYear = origin.dateYear;
+        dateYearMatchGroup = origin.dateYearMatchGroup;
+        dateMonth = origin.dateMonth;
+        dateMonthMatchGroup = origin.dateMonthMatchGroup;
+        dateDay = origin.dateDay;
+        dateDayMatchGroup = origin.dateDayMatchGroup;
+    }
     public String getTestText() {
         return testText;
     }
index a40ecae924417214d543e880421fb1e3d2b92e3e..60d56a5fbaa12aa5c7668ac7c75b953b05555544 100644 (file)
@@ -20,6 +20,7 @@ package net.ktnx.mobileledger.db;
 import androidx.room.Embedded;
 import androidx.room.Relation;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class TemplateWithAccounts {
@@ -28,6 +29,16 @@ public class TemplateWithAccounts {
     @Relation(parentColumn = "id", entityColumn = "template_id")
     public List<TemplateAccount> accounts;
 
+    public static TemplateWithAccounts from(TemplateWithAccounts o) {
+        TemplateWithAccounts result = new TemplateWithAccounts();
+        result.header = new TemplateHeader(o.header);
+        result.accounts = new ArrayList<>();
+        for (TemplateAccount acc : o.accounts) {
+            result.accounts.add(new TemplateAccount(acc));
+        }
+
+        return result;
+    }
     public Long getId() {
         return header.getId();
     }