Skip to content

FINERACT-xxxx: Add equals() and hashCode() to LoanTransaction#5855

Open
Harshdhall01 wants to merge 1 commit into
apache:developfrom
Harshdhall01:fix/loan-transaction-equals-hashcode
Open

FINERACT-xxxx: Add equals() and hashCode() to LoanTransaction#5855
Harshdhall01 wants to merge 1 commit into
apache:developfrom
Harshdhall01:fix/loan-transaction-equals-hashcode

Conversation

@Harshdhall01
Copy link
Copy Markdown

Description

LoanTransaction was missing equals() and hashCode() implementations,
flagged by a long-standing TODO comment in the code:

// TODO missing hashCode(), equals(Object obj), but probably OK as long as
// this is never stored in a Collection.

The parent class AbstractPersistableCustom intentionally omits these methods
(documented in its own Javadoc). Added id-based implementations consistent with
the pattern already used in LoanDisbursementDetails, ensuring correct behavior
if LoanTransaction is ever used in hash-based collections.

Changes

  • Removed stale TODO comment
  • Added equals() based on entity id with null-safety for unsaved entities
  • Added hashCode() based on entity id
  • Added missing java.util.Objects import

Note: JIRA ticket will be linked once Apache JIRA account approval is received.


I am exploring this codebase as part of my DMP 2026 (C4GT) application for the
"Dynamic Pricing of Micro-loans Using Reinforcement Learning" project under
openMF/Mifos. The loan module is directly relevant as it contains the core
transaction logic that my RL environment will model for dynamic pricing decisions.

Checklist

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build
  • Create/update unit or integration tests for verifying the changes made
  • Follow our coding conventions
  • Add required Swagger annotation and update API documentation
  • This PR must not be a "code dump"

LoanTransaction was missing equals() and hashCode() implementations,
noted by a TODO comment since the parent class AbstractPersistableCustom
intentionally omits them. Added id-based implementations consistent
with the pattern used in LoanDisbursementDetails, ensuring correct
behavior if LoanTransaction is ever used in hash-based collections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant