add null safe tests for standard account types

This commit is contained in:
Craig Raw 2023-11-15 10:51:44 +02:00
parent 28551247c6
commit 94aafbc11e
2 changed files with 14 additions and 2 deletions

View file

@ -67,4 +67,16 @@ public enum StandardAccount {
public String toString() { public String toString() {
return name; return name;
} }
public static boolean isMixableAccount(StandardAccount standardAccount) {
return standardAccount != null && MIXABLE_ACCOUNTS.contains(standardAccount);
}
public static boolean isWhirlpoolAccount(StandardAccount standardAccount) {
return standardAccount != null && WHIRLPOOL_ACCOUNTS.contains(standardAccount);
}
public static boolean isWhirlpoolMixAccount(StandardAccount standardAccount) {
return standardAccount != null && WHIRLPOOL_MIX_ACCOUNTS.contains(standardAccount);
}
} }

View file

@ -358,11 +358,11 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
} }
public boolean isWhirlpoolChildWallet() { public boolean isWhirlpoolChildWallet() {
return !isMasterWallet() && getStandardAccountType() != null && StandardAccount.WHIRLPOOL_ACCOUNTS.contains(getStandardAccountType()); return !isMasterWallet() && getStandardAccountType() != null && StandardAccount.isWhirlpoolAccount(getStandardAccountType());
} }
public boolean isWhirlpoolMixWallet() { public boolean isWhirlpoolMixWallet() {
return !isMasterWallet() && getMasterWallet().isWhirlpoolMasterWallet() && StandardAccount.WHIRLPOOL_MIX_ACCOUNTS.contains(getStandardAccountType()); return !isMasterWallet() && getMasterWallet().isWhirlpoolMasterWallet() && StandardAccount.isWhirlpoolMixAccount(getStandardAccountType());
} }
public void setName(String name) { public void setName(String name) {