]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java
AccountRow: copy constructor
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / TemplateDetailsItem.java
index 0f9cfe490b84e00f8053cb3b35947c49a5196c5f..d0a6e240f27472e3196fb524819362628103d9eb 100644 (file)
@@ -102,6 +102,7 @@ abstract public class TemplateDetailsItem {
             TemplateAccount pa = (TemplateAccount) p;
             AccountRow acc = createAccountRow();
             acc.setId(pa.getId());
+            acc.setPosition(pa.getPosition());
 
             if (pa.getAccountNameMatchGroup() == null)
                 acc.setAccountName(Misc.nullIsEmpty(pa.getAccountName()));
@@ -225,6 +226,11 @@ abstract public class TemplateDetailsItem {
             result.setValue(initialValue);
             return result;
         }
+        public void copyFrom(@NonNull PossiblyMatchedValue<T> origin) {
+            literalValue = origin.literalValue;
+            value = origin.value;
+            matchGroup = origin.matchGroup;
+        }
         public T getValue() {
             if (!literalValue)
                 throw new IllegalStateException("Value is not literal");
@@ -286,9 +292,19 @@ abstract public class TemplateDetailsItem {
                 PossiblyMatchedValue.withLiteralFloat(null);
         private final PossiblyMatchedValue<Currency> currency = new PossiblyMatchedValue<>();
         private boolean negateAmount;
-        private AccountRow() {
+        public AccountRow() {
             super(Type.ACCOUNT_ITEM);
         }
+        public AccountRow(AccountRow origin) {
+            super(Type.ACCOUNT_ITEM);
+            id = origin.id;
+            position = origin.position;
+            accountName.copyFrom(origin.accountName);
+            accountComment.copyFrom(origin.accountComment);
+            amount.copyFrom(origin.amount);
+            currency.copyFrom(origin.currency);
+            negateAmount = origin.negateAmount;
+        }
         public boolean isNegateAmount() {
             return negateAmount;
         }