import java.util.regex.Pattern;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
public class LedgerAccount {
static Pattern reHigherAccount = Pattern.compile("^[^:]+:");
this.amounts = new ArrayList<LedgerAmount>();
this.addAmount(amount);
}
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (obj == null) return false;
+
+ return obj.getClass().equals(this.getClass()) &&
+ name.equals(((LedgerAccount) obj).getName());
+ }
// an account is visible if:
// - it is starred (not hidden by a star)
// - and it has an expanded parent or is a top account
if (level == 0) return true;
- return isVisible(Data.accounts.get());
+ return isVisible(Data.accounts);
}
- public boolean isVisible(ArrayList<LedgerAccount> list) {
+ public boolean isVisible(List<LedgerAccount> list) {
for (LedgerAccount acc : list) {
if (acc.isParentOf(this)) {
if (!acc.isExpanded()) return false;