]> git.ktnx.net Git - mobile-ledger.git/commitdiff
New transaction Item: variant of ensureType with two allowed types
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 17 Nov 2019 17:14:50 +0000 (19:14 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 17 Nov 2019 17:14:50 +0000 (19:14 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java

index 75429a9921152f7c339eee245c85a55d1f2d0c89..54867e4da3321cb490fa6f8a2b334649a4066d2e 100644 (file)
@@ -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();