more nuanced wallet compare with master wallets first

This commit is contained in:
Craig Raw 2022-01-25 13:46:02 +01:00
parent fe61c633ae
commit 61317f15ac

View file

@ -1534,11 +1534,31 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
@Override
public int compareTo(Wallet other) {
if(getStandardAccountType() != null && other.getStandardAccountType() != null) {
return getStandardAccountType().ordinal() - other.getStandardAccountType().ordinal();
if(isMasterWallet() && !other.isMasterWallet()) {
return -1;
}
return getAccountIndex() - other.getAccountIndex();
if(!isMasterWallet() && other.isMasterWallet()) {
return 1;
}
if(getStandardAccountType() != null && other.getStandardAccountType() != null) {
int standardAccountDiff = getStandardAccountType().ordinal() - other.getStandardAccountType().ordinal();
if(standardAccountDiff != 0) {
return standardAccountDiff;
}
}
int accountIndexDiff = getAccountIndex() - other.getAccountIndex();
if(accountIndexDiff != 0) {
return accountIndexDiff;
}
if(name != null && other.name != null) {
return name.compareTo(other.name);
}
return 0;
}
@Override