From: Damyan Ivanov Date: Mon, 8 Feb 2021 05:49:33 +0000 (+0000) Subject: AccountRow: copy constructor X-Git-Tag: v0.17.0~105 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=f11c8a93f92f5a372ea423cdf2d3d9629bd5f45f;p=mobile-ledger.git AccountRow: copy constructor --- diff --git a/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java b/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java index 7c333866..d0a6e240 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/TemplateDetailsItem.java @@ -226,6 +226,11 @@ abstract public class TemplateDetailsItem { result.setValue(initialValue); return result; } + public void copyFrom(@NonNull PossiblyMatchedValue 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 = 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; }