Skip to content

Commit

Permalink
FINERACT-2056: (chore) introduce builder pattern and remove redundant…
Browse files Browse the repository at this point in the history
… methods & constructors.

- used @Getter & @builder annotations on the above of GroupSavingsIndividualMonitoringAccountData.
- removed the getters and getInstance() methods from the implementation.
- change GSIMReadPlatformServiceImpl to make use of the new implementation.
  • Loading branch information
Zeyad2003 authored and adamsaghy committed Apr 11, 2024
1 parent fe85677 commit 5ad6375
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
package org.apache.fineract.portfolio.savings.data;

import java.math.BigDecimal;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public final class GroupSavingsIndividualMonitoringAccountData {

private final BigDecimal gsimId;
Expand All @@ -42,80 +46,4 @@ public final class GroupSavingsIndividualMonitoringAccountData {
private final Long childAccountsCount;

private final String savingsStatus;

private GroupSavingsIndividualMonitoringAccountData(final BigDecimal glimId, final BigDecimal groupId, final BigDecimal clientId,
final String accountNumber, final BigDecimal childAccountId, final String childAccountNumber, final BigDecimal childDeposit,
final BigDecimal parentDeposit, final Long childAccountsCount, final String savingsStatus) {
this.gsimId = glimId;
this.groupId = groupId;
this.clientId = clientId;
this.accountNumber = accountNumber;
this.childAccountId = childAccountId;
this.childAccountNumber = childAccountNumber;
this.childDeposit = childDeposit;
this.parentDeposit = parentDeposit;
this.childAccountsCount = childAccountsCount;
this.savingsStatus = savingsStatus;
}

public static GroupSavingsIndividualMonitoringAccountData getInstance(final BigDecimal glimId, final BigDecimal groupId,
final String accountNumber, final String childAccountNumber, final BigDecimal childDeposit, final BigDecimal parentDeposit,
final Long childAccountsCount, final String savingsStatus) {
return new GroupSavingsIndividualMonitoringAccountData(glimId, groupId, null, accountNumber, null, childAccountNumber, childDeposit,
parentDeposit, childAccountsCount, savingsStatus);
}

public static GroupSavingsIndividualMonitoringAccountData getInstance1(final BigDecimal glimId, final BigDecimal groupId,
final String accountNumber, final BigDecimal parentDeposit, final String savingsStatus) {
return new GroupSavingsIndividualMonitoringAccountData(glimId, groupId, null, accountNumber, null, null, null, parentDeposit, null,
savingsStatus);
}

public static GroupSavingsIndividualMonitoringAccountData getInstance2(final BigDecimal glimId, final BigDecimal groupId,
final BigDecimal clientId, final String accountNumber, final BigDecimal childAccountId, final String childAccountNumber,
final BigDecimal childDeposit, final BigDecimal parentDeposit, final Long childAccountsCount, final String savingsStatus) {
return new GroupSavingsIndividualMonitoringAccountData(glimId, groupId, clientId, accountNumber, childAccountId, childAccountNumber,
childDeposit, parentDeposit, childAccountsCount, savingsStatus);
}

public BigDecimal getGsimId() {
return gsimId;
}

public BigDecimal getGroupId() {
return groupId;
}

public BigDecimal getClientId() {
return clientId;
}

public String getAccountNumber() {
return accountNumber;
}

public BigDecimal getChildAccountId() {
return childAccountId;
}

public String getChildAccountNumber() {
return childAccountNumber;
}

public BigDecimal getChildDeposit() {
return childDeposit;
}

public BigDecimal getParentDeposit() {
return parentDeposit;
}

public Long getChildAccountsCount() {
return childAccountsCount;
}

public String getSavingsStatus() {
return savingsStatus;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public GroupSavingsIndividualMonitoringAccountData mapRow(final ResultSet rs, @S
final BigDecimal parentBalance = rs.getBigDecimal("parentBalance");
final BigDecimal childBalance = rs.getBigDecimal("childBalance");
final String savingsStatus = SavingsAccountStatusType.fromInt((int) rs.getLong("savingsStatus")).toString();
return GroupSavingsIndividualMonitoringAccountData.getInstance2(gsimId, groupId, clientId, accountNumber, childAccountId,
childAccountNumber, parentBalance, childBalance, childAccountsCount, savingsStatus);

return GroupSavingsIndividualMonitoringAccountData.builder().gsimId(gsimId).groupId(groupId).clientId(clientId)
.accountNumber(accountNumber).childAccountId(childAccountId).childAccountNumber(childAccountNumber)
.childDeposit(parentBalance).parentDeposit(childBalance).childAccountsCount(childAccountsCount)
.savingsStatus(savingsStatus).build();
}
}

Expand All @@ -99,8 +102,8 @@ public GroupSavingsIndividualMonitoringAccountData mapRow(final ResultSet rs, @S

final String loanStatus = LoanStatus.fromInt((int) rs.getLong("savingsStatus")).toString();

return GroupSavingsIndividualMonitoringAccountData.getInstance1(glimId, groupId, accountNumber, parentDeposit, loanStatus);

return GroupSavingsIndividualMonitoringAccountData.builder().gsimId(glimId).groupId(groupId).accountNumber(accountNumber)
.parentDeposit(parentDeposit).savingsStatus(loanStatus).build();
}
}

Expand Down

0 comments on commit 5ad6375

Please sign in to comment.