From caee580f62402d32eb743eb2897cde923f8c72e7 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 17 Nov 2019 19:14:50 +0200 Subject: [PATCH] New transaction Item: variant of ensureType with two allowed types --- .../ktnx/mobileledger/ui/activity/NewTransactionModel.java | 7 +++++++ 1 file changed, 7 insertions(+) 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(); -- 2.39.5