From: Damyan Ivanov Date: Sun, 17 Nov 2019 17:14:50 +0000 (+0200) Subject: New transaction Item: variant of ensureType with two allowed types X-Git-Tag: v0.11.0~58 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger-staging.git;a=commitdiff_plain;h=caee580f62402d32eb743eb2897cde923f8c72e7 New transaction Item: variant of ensureType with two allowed types --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java index 75429a99..54867e4d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java @@ -280,6 +280,13 @@ public class NewTransactionModel extends ViewModel { ensureType(ItemType.transactionRow); this.editable.setValue(editable); } + private void ensureType(ItemType type1, ItemType type2) { + if ((type != type1) && (type != type2)) { + throw new RuntimeException( + String.format("Actual type (%s) differs from wanted (%s or %s)", type, + type1, type2)); + } + } public String getAmountHint() { ensureType(ItemType.transactionRow); return amountHint.getValue();