X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fmodel%2FCurrency.java;h=e32513f2170a9ecba710631ea86a168df6f14ef7;hb=34ded721286cec1412780c4b0b66c07029fffbe8;hp=a4854c05219c146608326b1acf8f2556f5aebd25;hpb=5545ddea3574103c2a7eea552fff0d43a0587fac;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/model/Currency.java b/app/src/main/java/net/ktnx/mobileledger/model/Currency.java index a4854c05..e32513f2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/Currency.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/Currency.java @@ -24,6 +24,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.DiffUtil; import net.ktnx.mobileledger.App; +import net.ktnx.mobileledger.utils.Misc; public class Currency { public static final DiffUtil.ItemCallback DIFF_CALLBACK = @@ -79,6 +80,10 @@ public class Currency { this.position = position; this.hasGap = hasGap; } + public static Currency loadByName(String name) { + MobileLedgerProfile profile = Data.profile.getValue(); + return profile.loadCurrencyByName(name); + } public int getId() { return id; } @@ -100,6 +105,27 @@ public class Currency { public void setHasGap(boolean hasGap) { this.hasGap = hasGap; } + static public boolean equal(Currency left, Currency right) { + if (left == null) { + return right == null; + } + else + return left.equals(right); + } + static public boolean equal(Currency left, String right) { + right = Misc.emptyIsNull(right); + if (left == null) { + return right == null; + } + else { + String leftName = Misc.emptyIsNull(left.getName()); + if (leftName == null) { + return right == null; + } + else + return leftName.equals(right); + } + } public enum Position { before(-1), after(1), unknown(0), none(-2); private int value;