]> git.ktnx.net Git - mobile-ledger.git/commitdiff
AccountRow: copy constructor
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 8 Feb 2021 05:49:33 +0000 (05:49 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 07:34:20 +0000 (07:34 +0000)
app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java

index 7c33386670cd72619cde97179579fd7adc428876..d0a6e240f27472e3196fb524819362628103d9eb 100644 (file)
@@ -226,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");
@@ -287,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;
         }