FINERACT-2421: Refractor redundant and some deprecated code as per new Java 21 style (Phase 3)

This commit is contained in:
Aman-Mittal
2025-12-26 19:27:38 +01:00
committed by Adam Saghy
parent 7dac82a4fc
commit 0ba1745443
18 changed files with 82 additions and 145 deletions
@@ -3150,9 +3150,8 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
.orElse(null);
final List<LoanCharge> liftedLoanCharges = new ArrayList<>();
installments.stream().filter(installment -> !installment.getDueDate().isBefore(transactionDate)).forEach(i -> {
liftedLoanCharges.addAll(getLoanChargesOfInstallment(ctx.getCharges(), i, 1));
});
installments.stream().filter(installment -> !installment.getDueDate().isBefore(transactionDate))
.forEach(i -> liftedLoanCharges.addAll(getLoanChargesOfInstallment(ctx.getCharges(), i, 1)));
installments.removeIf(i -> i.getInstallmentNumber() != null && !i.isDownPayment() && !i.getDueDate().isBefore(transactionDate));
@@ -3308,10 +3307,10 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
private LocalDate calculateReAgedNextDate(final PeriodFrequencyType frequencyType, final LocalDate dueDate,
final Integer frequencyNumber) {
return switch (frequencyType) {
case DAYS -> dueDate.plusDays((long) frequencyNumber);
case WEEKS -> dueDate.plusWeeks((long) frequencyNumber);
case MONTHS -> dueDate.plusMonths((long) frequencyNumber);
case YEARS -> dueDate.plusYears((long) frequencyNumber);
case DAYS -> dueDate.plusDays(frequencyNumber);
case WEEKS -> dueDate.plusWeeks(frequencyNumber);
case MONTHS -> dueDate.plusMonths(frequencyNumber);
case YEARS -> dueDate.plusYears(frequencyNumber);
default -> throw new UnsupportedOperationException();
};
}
@@ -3799,10 +3798,8 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
private void createChargeMappingsForInstallment(final LoanRepaymentScheduleInstallment installment,
List<ReAgedChargeEqualAmortizationValues> reAgedChargeEqualAmortizationValues, Integer index) {
reAgedChargeEqualAmortizationValues.forEach(amortizationValue -> {
installment.getInstallmentCharges().add(new LoanInstallmentCharge(
amortizationValue.equalAmortizationValues.calculateValueBigDecimal(index), amortizationValue.charge, installment));
});
reAgedChargeEqualAmortizationValues.forEach(amortizationValue -> installment.getInstallmentCharges().add(new LoanInstallmentCharge(
amortizationValue.equalAmortizationValues.calculateValueBigDecimal(index), amortizationValue.charge, installment)));
}
private FirstReAgeInstallmentProps calculateFirstReAgeInstallmentProps(List<LoanRepaymentScheduleInstallment> installments,
@@ -78,9 +78,8 @@ public class AdvancedPaymentAllocationsValidator {
AtomicInteger pastDueRuleInteger = new AtomicInteger();
AtomicInteger dueRuleInteger = new AtomicInteger();
AtomicInteger inAdvanceRuleInteger = new AtomicInteger();
paymentAllocationRule.getAllocationTypes().forEach(paymentAllocationType -> {
validateAllocationType(paymentAllocationType, pastDueRuleInteger, dueRuleInteger, inAdvanceRuleInteger);
});
paymentAllocationRule.getAllocationTypes().forEach(paymentAllocationType -> validateAllocationType(paymentAllocationType,
pastDueRuleInteger, dueRuleInteger, inAdvanceRuleInteger));
});
}
@@ -122,14 +121,14 @@ public class AdvancedPaymentAllocationsValidator {
}
private boolean hasAtLeastOneDefaultPaymentAllocation(List<LoanProductPaymentAllocationRule> rules) {
return rules != null && rules.stream() //
return rules != null && !rules.stream() //
.filter(r -> PaymentAllocationTransactionType.DEFAULT.equals(r.getTransactionType())) //
.toList() //
.size() > 0;
.isEmpty();
}
private boolean hasLoanProductPaymentAllocationRule(List<LoanProductPaymentAllocationRule> rules) {
return rules != null && rules.size() > 0;
return rules != null && !rules.isEmpty();
}
private void raiseValidationError(String globalisationMessageCode, String msg) {