From 7a2af51e6c717ff1c2aa3fb08658a49122fb5b16 Mon Sep 17 00:00:00 2001 From: Adam Saghy Date: Fri, 19 Aug 2022 19:44:47 +0200 Subject: [PATCH] Code cleanup - loan product --- .../service/AuditReadPlatformServiceImpl.java | 2 +- .../loanaccount/api/LoansApiResource.java | 2 +- .../loanaccount/data/LoanAccountData.java | 4 +- .../GroupLoanIndividualMonitoringAccount.java | 4 +- .../portfolio/loanaccount/domain/Loan.java | 6 +- .../domain/LoanTermVariations.java | 2 +- .../domain/AbstractLoanScheduleGenerator.java | 8 +- .../domain/LoanApplicationTerms.java | 2 +- .../service/LoanScheduleAssembler.java | 6 +- ...cheduleRequestReadPlatformServiceImpl.java | 2 +- ...iableLoanScheduleFromApiJsonValidator.java | 4 +- .../service/LoanReadPlatformServiceImpl.java | 7 +- .../loanproduct/LoanProductConstants.java | 2 +- .../api/LoanProductsApiResource.java | 4 +- .../api/LoanProductsApiResourceSwagger.java | 8 +- .../loanproduct/data/LoanProductData.java | 12 +- .../domain/AmortizationMethod.java | 18 +- .../InterestCalculationPeriodMethod.java | 18 +- .../loanproduct/domain/InterestMethod.java | 20 +- ...nterestRecalculationCompoundingMethod.java | 3 +- .../InterestRecalculationPeriodMethod.java | 3 +- .../loanproduct/domain/LendingStrategy.java | 7 +- ...PreClosureInterestCalculationStrategy.java | 3 +- .../loanproduct/domain/LoanProduct.java | 139 ++-- .../LoanProductBorrowerCycleVariations.java | 4 +- .../LoanProductConfigurableAttributes.java | 24 +- .../domain/LoanProductFloatingRates.java | 2 +- .../domain/LoanProductGuaranteeDetails.java | 4 +- ...anProductInterestRecalculationDetails.java | 28 +- .../domain/LoanProductMinMaxConstraints.java | 12 +- .../domain/LoanProductParamType.java | 20 +- .../domain/LoanProductRelatedDetail.java | 30 +- .../domain/LoanProductTrancheDetails.java | 5 +- .../domain/LoanProductValueConditionType.java | 18 +- .../LoanProductVariableInstallmentConfig.java | 2 +- .../domain/LoanRescheduleStrategyMethod.java | 3 +- .../domain/RecalculationFrequencyType.java | 25 +- .../exception/InvalidLendingStrategy.java | 2 +- .../productmix/api/ProductMixApiResource.java | 2 +- .../ProductMixDataValidator.java | 3 +- .../ProductMixReadPlatformServiceImpl.java | 2 +- ...WritePlatformServiceJpaRepositoryImpl.java | 8 +- .../LoanProductDataValidator.java | 73 +- .../service/LendingStrategyEnumerations.java | 28 +- .../LoanDropdownReadPlatformService.java | 4 +- .../LoanDropdownReadPlatformServiceImpl.java | 81 +- .../loanproduct/service/LoanEnumerations.java | 779 ++++++------------ .../LoanProductReadPlatformServiceImpl.java | 22 +- ...WritePlatformServiceJpaRepositoryImpl.java | 4 +- .../LoanProductValidationStepDefinitions.java | 2 +- 50 files changed, 533 insertions(+), 940 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java index 2f63ef1fe..c1cd53adb 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java @@ -368,7 +368,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { commandAsJsonMap.remove(typeName); final Integer enumTypeId = auditObject.get(typeName).getAsInt(); - final String code = LoanEnumerations.loanEnumueration(typeName, enumTypeId).getValue(); + final String code = LoanEnumerations.loanEnumeration(typeName, enumTypeId).getValue(); if (code != null) { commandAsJsonMap.put(typeName, code); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java index f1ba37001..73b4bc084 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java @@ -647,7 +647,7 @@ public class LoansApiResource { interestCalculationPeriodTypeOptions = this.dropdownReadPlatformService.retrieveLoanInterestRateCalculatedInPeriodOptions(); fundOptions = this.fundReadPlatformService.retrieveAllFunds(); - repaymentStrategyOptions = this.dropdownReadPlatformService.retreiveTransactionProcessingStrategies(); + repaymentStrategyOptions = this.dropdownReadPlatformService.retrieveTransactionProcessingStrategies(); if (product.getMultiDisburseLoan()) { chargeOptions = this.chargeReadPlatformService.retrieveLoanAccountApplicableCharges(loanId, new ChargeTimeType[] { ChargeTimeType.OVERDUE_INSTALLMENT }); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanAccountData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanAccountData.java index b35ab55bb..38a8eafe3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanAccountData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanAccountData.java @@ -1333,7 +1333,7 @@ public final class LoanAccountData { final CollectionData delinquent) { LoanProductConfigurableAttributes loanProductConfigurableAttributes = null; if (acc.product != null) { - loanProductConfigurableAttributes = acc.product.getloanProductConfigurableAttributes(); + loanProductConfigurableAttributes = acc.product.getLoanProductConfigurableAttributes(); } return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientAccountNo, acc.clientName, @@ -1788,7 +1788,7 @@ public final class LoanAccountData { this.createStandingInstructionAtDisbursement = createStandingInstructionAtDisbursement; this.paidInAdvance = paidInAdvance; if (this.product != null) { - this.product.setloanProductConfigurableAttributes(product.getloanProductConfigurableAttributes()); + this.product.setLoanProductConfigurableAttributes(product.getLoanProductConfigurableAttributes()); } this.interestRatesPeriods = interestRatesPeriods; this.isVariableInstallmentsAllowed = isVariableInstallmentsAllowed; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/GroupLoanIndividualMonitoringAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/GroupLoanIndividualMonitoringAccount.java index d33e729a3..36b6f07e3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/GroupLoanIndividualMonitoringAccount.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/GroupLoanIndividualMonitoringAccount.java @@ -33,7 +33,7 @@ import org.apache.fineract.portfolio.group.domain.Group; @Entity @Table(name = "glim_accounts", uniqueConstraints = { @UniqueConstraint(columnNames = { "account_number" }, name = "FK_glim_id") }) -public final class GroupLoanIndividualMonitoringAccount extends AbstractPersistableCustom { +public class GroupLoanIndividualMonitoringAccount extends AbstractPersistableCustom { @ManyToOne @JoinColumn(name = "group_id", nullable = false) @@ -60,7 +60,7 @@ public final class GroupLoanIndividualMonitoringAccount extends AbstractPersista @Column(name = "application_id", nullable = true) private BigDecimal applicationId; - private GroupLoanIndividualMonitoringAccount() {} + protected GroupLoanIndividualMonitoringAccount() {} private GroupLoanIndividualMonitoringAccount(String accountNumber, Group group, BigDecimal principalAmount, Long childAccountsCount, Boolean isAcceptingChild, Integer loanStatus, BigDecimal applicationId) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index 5ca69a919..974894682 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -2769,7 +2769,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom { final LoanApplicationTerms loanApplicationTerms = constructLoanApplicationTerms(scheduleGeneratorDTO); LoanScheduleGenerator loanScheduleGenerator = null; if (loanApplicationTerms.isEqualAmortization()) { - if (loanApplicationTerms.getInterestMethod().isDecliningBalnce()) { + if (loanApplicationTerms.getInterestMethod().isDecliningBalance()) { final LoanScheduleGenerator decliningLoanScheduleGenerator = scheduleGeneratorDTO.getLoanScheduleFactory() .create(InterestMethod.DECLINING_BALANCE); Set loanCharges = charges(); @@ -2801,7 +2801,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom { LocalDate interestRateStartDate = DateUtils.getBusinessLocalDate(); for (FloatingRatePeriodData periodData : applicableRates) { LoanTermVariationsData loanTermVariation = new LoanTermVariationsData( - LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(), + LoanEnumerations.loanVariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(), periodData.getInterestRate(), dateValue, isSpecificToInstallment); if (!interestRateStartDate.isBefore(periodData.getFromDateAsLocalDate())) { interestRateStartDate = periodData.getFromDateAsLocalDate(); @@ -4771,7 +4771,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom { } public void updateInterestRateFrequencyType() { - this.loanRepaymentScheduleDetail.updatenterestPeriodFrequencyType(this.loanProduct.getInterestPeriodFrequencyType()); + this.loanRepaymentScheduleDetail.updateInterestPeriodFrequencyType(this.loanProduct.getInterestPeriodFrequencyType()); } public Integer getTermFrequency() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java index 330f3621c..f2df0444b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java @@ -114,7 +114,7 @@ public class LoanTermVariations extends AbstractPersistableCustom { } public LoanTermVariationsData toData() { - EnumOptionData type = LoanEnumerations.loanvariationType(this.termType); + EnumOptionData type = LoanEnumerations.loanVariationType(this.termType); return new LoanTermVariationsData(getId(), type, this.termApplicableFrom, this.decimalValue, this.dateValue, this.isSpecificToInstallment); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java index 1465baaf4..6e6dd81c2 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/AbstractLoanScheduleGenerator.java @@ -1018,7 +1018,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener for (LoanTermVariationsData variation : interestRatesForInstallments) { if (variation.isApplicable(modifiedScheduledDueDate) && variation.getDecimalValue() != null && !variation.isProcessed()) { loanApplicationTerms.updateAnnualNominalInterestRate(variation.getDecimalValue()); - if (loanApplicationTerms.getInterestMethod().isDecliningBalnce()) { + if (loanApplicationTerms.getInterestMethod().isDecliningBalance()) { if (loanApplicationTerms.getActualFixedEmiAmount() == null) { loanApplicationTerms.setFixedEmiAmount(null); } @@ -1046,7 +1046,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener scheduleParams.setActualRepaymentDate(previousRepaymentDate); modifiedScheduledDueDate = loanTermVariationsData.getTermApplicableFrom(); if (loanTermVariationsData.getDecimalValue() != null) { - if (loanApplicationTerms.getInterestMethod().isDecliningBalnce() + if (loanApplicationTerms.getInterestMethod().isDecliningBalance() && loanApplicationTerms.getAmortizationMethod().isEqualInstallment()) { loanApplicationTerms.setCurrentPeriodFixedEmiAmount(loanTermVariationsData.getDecimalValue()); } else { @@ -1144,7 +1144,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener for (LoanTermVariationsData variation : loanApplicationTerms.getLoanTermVariations().getInterestRateFromInstallment()) { if (variation.isApplicable(modifiedScheduledDueDate) && variation.getDecimalValue() != null && !variation.isProcessed()) { loanApplicationTerms.updateAnnualNominalInterestRate(variation.getDecimalValue()); - if (loanApplicationTerms.getInterestMethod().isDecliningBalnce()) { + if (loanApplicationTerms.getInterestMethod().isDecliningBalance()) { adjustInstallmentOrPrincipalAmount(loanApplicationTerms, totalCumulativePrincipal, instalmentNumber, mc); } else { loanApplicationTerms.setTotalPrincipalAccountedForInterestCalculation(totalCumulativePrincipal); @@ -1270,7 +1270,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener private boolean updateFixedInstallmentAmount(final MathContext mc, final LoanApplicationTerms loanApplicationTerms, int periodNumber, Money outstandingBalance) { boolean isAmountChanged = false; - if (loanApplicationTerms.getActualFixedEmiAmount() == null && loanApplicationTerms.getInterestMethod().isDecliningBalnce() + if (loanApplicationTerms.getActualFixedEmiAmount() == null && loanApplicationTerms.getInterestMethod().isDecliningBalance() && loanApplicationTerms.getAmortizationMethod().isEqualInstallment()) { if (periodNumber < loanApplicationTerms.getPrincipalGrace() + 1) { periodNumber = loanApplicationTerms.getPrincipalGrace() + 1; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java index 0e8bb7c33..c1679eebe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java @@ -691,7 +691,7 @@ public final class LoanApplicationTerms { } switch (interestMethod) { case FLAT: - if (this.isEqualAmortization() && this.totalInterestDue != null && this.interestMethod.isDecliningBalnce()) { + if (this.isEqualAmortization() && this.totalInterestDue != null && this.interestMethod.isDecliningBalance()) { interestForInstallment = flatInterestPerInstallment(mc, this.totalInterestDue); } else { switch (this.amortizationMethod) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java index 2b6ff390b..9a55c6ed6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java @@ -420,7 +420,7 @@ public class LoanScheduleAssembler { final boolean isSpecificToInstallment = false; for (FloatingRatePeriodData periodData : applicableRates) { LoanTermVariationsData loanTermVariation = new LoanTermVariationsData( - LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(), + LoanEnumerations.loanVariationType(LoanTermVariationType.INTEREST_RATE), periodData.getFromDateAsLocalDate(), periodData.getInterestRate(), dateValue, isSpecificToInstallment); if (!interestRateStartDate.isBefore(periodData.getFromDateAsLocalDate())) { interestRateStartDate = periodData.getFromDateAsLocalDate(); @@ -644,7 +644,7 @@ public class LoanScheduleAssembler { LoanScheduleGenerator loanScheduleGenerator = this.loanScheduleFactory.create(loanApplicationTerms.getInterestMethod()); if (loanApplicationTerms.isEqualAmortization()) { - if (loanApplicationTerms.getInterestMethod().isDecliningBalnce()) { + if (loanApplicationTerms.getInterestMethod().isDecliningBalance()) { final LoanScheduleGenerator decliningLoanScheduleGenerator = this.loanScheduleFactory .create(InterestMethod.DECLINING_BALANCE); LoanScheduleModel loanSchedule = decliningLoanScheduleGenerator.generate(mc, loanApplicationTerms, loanCharges, detailDTO); @@ -993,7 +993,7 @@ public class LoanScheduleAssembler { BigDecimal decimalValue = null; LoanTermVariationType decimalValueVariationType = LoanTermVariationType.INVALID; if (loan.getLoanProductRelatedDetail().getAmortizationMethod().isEqualInstallment() - && loan.getLoanProductRelatedDetail().getInterestMethod().isDecliningBalnce()) { + && loan.getLoanProductRelatedDetail().getInterestMethod().isDecliningBalance()) { decimalValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanApiConstants.installmentAmountParamName, arrayElement, locale); decimalValueVariationType = LoanTermVariationType.EMI_AMOUNT; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestReadPlatformServiceImpl.java index a32550a2b..368e99f42 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestReadPlatformServiceImpl.java @@ -182,7 +182,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched final boolean isSpecificToInstallment = rs.getBoolean("isSpecificToInstallment"); final int termType = rs.getInt("termType"); - return new LoanTermVariationsData(id, LoanEnumerations.loanvariationType(termType), variationApplicableFrom, decimalValue, + return new LoanTermVariationsData(id, LoanEnumerations.loanVariationType(termType), variationApplicableFrom, decimalValue, dateValue, isSpecificToInstallment); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/VariableLoanScheduleFromApiJsonValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/VariableLoanScheduleFromApiJsonValidator.java index 6cd841246..7dcafd81e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/VariableLoanScheduleFromApiJsonValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/VariableLoanScheduleFromApiJsonValidator.java @@ -133,12 +133,12 @@ public class VariableLoanScheduleFromApiJsonValidator { baseDataValidator.reset().parameter(arrayName).parameterAtIndexArray(LoanApiConstants.principalParamName, i) .value(principalAmount).zeroOrPositiveAmount(); - if (loan.getLoanProductRelatedDetail().getInterestMethod().isDecliningBalnce() + if (loan.getLoanProductRelatedDetail().getInterestMethod().isDecliningBalance() && loan.getLoanProductRelatedDetail().getAmortizationMethod().isEqualInstallment() && principalAmount != null) { List unsupportedParams = new ArrayList<>(1); unsupportedParams.add(LoanApiConstants.principalParamName); throw new UnsupportedParameterException(unsupportedParams); - } else if ((!loan.getLoanProductRelatedDetail().getInterestMethod().isDecliningBalnce() + } else if ((!loan.getLoanProductRelatedDetail().getInterestMethod().isDecliningBalance() || loan.getLoanProductRelatedDetail().getAmortizationMethod().isEqualPrincipal()) && installmentAmount != null) { List unsupportedParams = new ArrayList<>(1); unsupportedParams.add(LoanApiConstants.installmentAmountParamName); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index 4fbb9bb2a..385c944f3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -121,6 +121,7 @@ import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.apache.fineract.useradministration.domain.AppUser; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; @@ -1097,7 +1098,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { } @Override - public LoanScheduleData extractData(final ResultSet rs) throws SQLException, DataAccessException { + public LoanScheduleData extractData(@NotNull final ResultSet rs) throws SQLException, DataAccessException { BigDecimal waivedChargeAmount = BigDecimal.ZERO; for (DisbursementData disbursementDetail : disbursementData) { waivedChargeAmount = waivedChargeAmount.add(disbursementDetail.getWaivedChargeAmount()); @@ -1427,7 +1428,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { .retrieveLoanInterestRateCalculatedInPeriodOptions(); final Collection fundOptions = this.fundReadPlatformService.retrieveAllFunds(); final Collection repaymentStrategyOptions = this.loanDropdownReadPlatformService - .retreiveTransactionProcessingStrategies(); + .retrieveTransactionProcessingStrategies(); final Collection loanPurposeOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode("LoanPurpose"); final Collection loanCollateralOptions = this.codeValueReadPlatformService .retrieveCodeValuesByCode("LoanCollateral"); @@ -1642,7 +1643,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final LocalDate dateValue = JdbcSupport.getLocalDate(rs, "dateValue"); final boolean isSpecificToInstallment = rs.getBoolean("isSpecificToInstallment"); - return new LoanTermVariationsData(id, LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT), + return new LoanTermVariationsData(id, LoanEnumerations.loanVariationType(LoanTermVariationType.EMI_AMOUNT), variationApplicableFrom, decimalValue, dateValue, isSpecificToInstallment); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/LoanProductConstants.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/LoanProductConstants.java index 45b26be85..a38dee9f2 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/LoanProductConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/LoanProductConstants.java @@ -65,7 +65,7 @@ public interface LoanProductConstants { String MIN_NUMBER_OF_REPAYMENTS = "minNumberOfRepayments"; String MAX_NUMBER_OF_REPAYMENTS = "maxNumberOfRepayments"; - String VALUE_CONDITION_END_WITH_ERROR = "condition.type.must.end.with.greterthan"; + String VALUE_CONDITION_END_WITH_ERROR = "condition.type.must.end.with.greater.than"; String VALUE_CONDITION_START_WITH_ERROR = "condition.type.must.start.with.equal"; String SHORT_NAME = "shortName"; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java index 346fc68e3..48c511818 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -351,7 +351,7 @@ public class LoanProductsApiResource { } final Collection transactionProcessingStrategyOptions = this.dropdownReadPlatformService - .retreiveTransactionProcessingStrategies(); + .retrieveTransactionProcessingStrategies(); final Map> accountOptions = this.accountingDropdownReadPlatformService .retrieveAccountMappingOptionsForLoanProducts(); @@ -374,7 +374,7 @@ public class LoanProductsApiResource { final List interestRecalculationDayOfWeekTypeOptions = dropdownReadPlatformService .retrieveInterestRecalculationDayOfWeekTypeOptions(); final List preCloseInterestCalculationStrategyOptions = dropdownReadPlatformService - .retrivePreCloseInterestCalculationStrategyOptions(); + .retrievePreCloseInterestCalculationStrategyOptions(); final List floatingRateOptions = this.floatingRateReadPlatformService.retrieveLookupActive(); return new LoanProductData(productData, chargeOptions, penaltyOptions, paymentTypeOptions, currencyOptions, amortizationTypeOptions, diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java index 5413368bc..bd702a66f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java @@ -530,17 +530,17 @@ final class LoanProductsApiResourceSwagger { private GetLoanProductsTemplateCurrency() {} - @Schema(example = "") + @Schema(example = "USD") public String code; - @Schema(example = "") + @Schema(example = "Usa dollar") public String name; @Schema(example = "0") public Integer decimalPlaces; @Schema(example = "0") public Integer inMultiplesOf; - @Schema(example = "") + @Schema(example = "$") public String displaySymbol; - @Schema(example = "") + @Schema(example = "USD") public String nameCode; @Schema(example = "[]") public String displayLabel; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java index 5385884fa..b9a0ee699 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductData.java @@ -254,7 +254,7 @@ public class LoanProductData implements Serializable { final Integer overAppliedNumber = null; final LoanProductGuaranteeData productGuaranteeData = null; - final Boolean holdGuaranteeFunds = false; + final boolean holdGuaranteeFunds = false; final BigDecimal principalThresholdForLastInstallment = null; final BigDecimal fixedPrincipalPercentagePerInstallment = null; final boolean accountMovesOutOfNPAOnlyOnArrearsCompletion = false; @@ -364,7 +364,7 @@ public class LoanProductData implements Serializable { final boolean isInterestRecalculationEnabled = false; final LoanProductInterestRecalculationData interestRecalculationData = null; final Integer minimumDaysBetweenDisbursalAndFirstRepayment = null; - final Boolean holdGuaranteeFunds = false; + final boolean holdGuaranteeFunds = false; final LoanProductGuaranteeData productGuaranteeData = null; final BigDecimal principalThresholdForLastInstallment = null; final BigDecimal fixedPrincipalPercentagePerInstallment = null; @@ -476,7 +476,7 @@ public class LoanProductData implements Serializable { final LoanProductInterestRecalculationData interestRecalculationData = LoanProductInterestRecalculationData .sensibleDefaultsForNewLoanProductCreation(); final Integer minimumDaysBetweenDisbursalAndFirstRepayment = null; - final Boolean holdGuaranteeFunds = false; + final boolean holdGuaranteeFunds = false; final LoanProductGuaranteeData productGuaranteeData = null; final BigDecimal principalThresholdForLastInstallment = null; final BigDecimal fixedPrincipalPercentagePerInstallment = null; @@ -582,7 +582,7 @@ public class LoanProductData implements Serializable { final LoanProductInterestRecalculationData interestRecalculationData = LoanProductInterestRecalculationData .sensibleDefaultsForNewLoanProductCreation(); final Integer minimumDaysBetweenDisbursalAndFirstRepayment = null; - final Boolean holdGuaranteeFunds = false; + final boolean holdGuaranteeFunds = false; final LoanProductGuaranteeData productGuaranteeData = null; final BigDecimal principalThresholdForLastInstallment = null; final BigDecimal fixedPrincipalPercentagePerInstallment = null; @@ -1265,11 +1265,11 @@ public class LoanProductData implements Serializable { return this.canDefineInstallmentAmount; } - public LoanProductConfigurableAttributes getloanProductConfigurableAttributes() { + public LoanProductConfigurableAttributes getLoanProductConfigurableAttributes() { return this.allowAttributeOverrides; } - public void setloanProductConfigurableAttributes(LoanProductConfigurableAttributes loanProductConfigurableAttributes) { + public void setLoanProductConfigurableAttributes(LoanProductConfigurableAttributes loanProductConfigurableAttributes) { this.allowAttributeOverrides = loanProductConfigurableAttributes; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AmortizationMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AmortizationMethod.java index edeb14d87..44bb13f61 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AmortizationMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AmortizationMethod.java @@ -46,19 +46,11 @@ public enum AmortizationMethod { return null; } - AmortizationMethod repaymentMethod = null; - switch (selectedMethod) { - case 0: - repaymentMethod = AmortizationMethod.EQUAL_PRINCIPAL; - break; - case 1: - repaymentMethod = AmortizationMethod.EQUAL_INSTALLMENTS; - break; - default: - repaymentMethod = AmortizationMethod.INVALID; - break; - } - return repaymentMethod; + return switch (selectedMethod) { + case 0 -> AmortizationMethod.EQUAL_PRINCIPAL; + case 1 -> AmortizationMethod.EQUAL_INSTALLMENTS; + default -> AmortizationMethod.INVALID; + }; } public boolean isEqualInstallment() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestCalculationPeriodMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestCalculationPeriodMethod.java index 048fd8aa6..5e5efdb05 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestCalculationPeriodMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestCalculationPeriodMethod.java @@ -42,19 +42,11 @@ public enum InterestCalculationPeriodMethod { public static InterestCalculationPeriodMethod fromInt(final Integer selectedMethod) { - InterestCalculationPeriodMethod repaymentMethod = null; - switch (selectedMethod) { - case 0: - repaymentMethod = InterestCalculationPeriodMethod.DAILY; - break; - case 1: - repaymentMethod = InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD; - break; - default: - repaymentMethod = InterestCalculationPeriodMethod.INVALID; - break; - } - return repaymentMethod; + return switch (selectedMethod) { + case 0 -> InterestCalculationPeriodMethod.DAILY; + case 1 -> InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD; + default -> InterestCalculationPeriodMethod.INVALID; + }; } public boolean isDaily() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestMethod.java index b3ad45238..46474090f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestMethod.java @@ -40,22 +40,14 @@ public enum InterestMethod { public static InterestMethod fromInt(final Integer selectedMethod) { - InterestMethod repaymentMethod = null; - switch (selectedMethod) { - case 0: - repaymentMethod = InterestMethod.DECLINING_BALANCE; - break; - case 1: - repaymentMethod = InterestMethod.FLAT; - break; - default: - repaymentMethod = InterestMethod.INVALID; - break; - } - return repaymentMethod; + return switch (selectedMethod) { + case 0 -> InterestMethod.DECLINING_BALANCE; + case 1 -> InterestMethod.FLAT; + default -> InterestMethod.INVALID; + }; } - public boolean isDecliningBalnce() { + public boolean isDecliningBalance() { return this.value.equals(InterestMethod.DECLINING_BALANCE.getValue()); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java index db6b84cdb..64a796dc3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationCompoundingMethod.java @@ -50,8 +50,7 @@ public enum InterestRecalculationCompoundingMethod { } public static InterestRecalculationCompoundingMethod fromInt(final Integer ruleTypeValue) { - final InterestRecalculationCompoundingMethod type = intToEnumMap.get(ruleTypeValue); - return type; + return intToEnumMap.get(ruleTypeValue); } InterestRecalculationCompoundingMethod(final Integer value, final String code) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java index fb5d326d4..cadc826a5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/InterestRecalculationPeriodMethod.java @@ -53,8 +53,7 @@ public enum InterestRecalculationPeriodMethod { } public static InterestRecalculationPeriodMethod fromInt(final Integer ruleTypeValue) { - final InterestRecalculationPeriodMethod type = intToEnumMap.get(ruleTypeValue); - return type; + return intToEnumMap.get(ruleTypeValue); } InterestRecalculationPeriodMethod(final Integer value, final String code) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LendingStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LendingStrategy.java index 182da5382..e78784c65 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LendingStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LendingStrategy.java @@ -30,7 +30,7 @@ import java.util.Map; */ public enum LendingStrategy { - INDIVIDUAL_LOAN(100, "lendingStrategy.individaulLoan", "individaulLoan"), // + INDIVIDUAL_LOAN(100, "lendingStrategy.individualLoan", "individualLoan"), // GROUP_LOAN(200, "lendingStrategy.groupLoan", "groupLoan"), // JOINT_LIABILITY_LOAN(300, "lendingStrategy.joinLiabilityLoan", "joinLiabilityLoan"), // LINKED_LOAN(400, "lendingStrategy.linkedLoan", "linkedLoan"), // @@ -68,8 +68,7 @@ public enum LendingStrategy { } public static LendingStrategy fromInt(final int i) { - final LendingStrategy type = intToEnumMap.get(Integer.valueOf(i)); - return type; + return intToEnumMap.get(i); } public static int getMinValue() { @@ -82,7 +81,7 @@ public enum LendingStrategy { @Override public String toString() { - return name().toString(); + return name(); } public Integer getId() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java index 93849708e..25ce5dd0b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java @@ -55,8 +55,7 @@ public enum LoanPreClosureInterestCalculationStrategy { } public static LoanPreClosureInterestCalculationStrategy fromInt(final Integer ruleTypeValue) { - final LoanPreClosureInterestCalculationStrategy type = intToEnumMap.get(ruleTypeValue); - return type; + return intToEnumMap.get(ruleTypeValue); } LoanPreClosureInterestCalculationStrategy(final Integer value, final String code) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java index 07a84cdb4..4ebe179aa 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java @@ -79,11 +79,11 @@ import org.apache.fineract.portfolio.rate.domain.Rate; public class LoanProduct extends AbstractPersistableCustom { @ManyToOne - @JoinColumn(name = "fund_id", nullable = true) + @JoinColumn(name = "fund_id") private Fund fund; @ManyToOne - @JoinColumn(name = "loan_transaction_strategy_id", nullable = true) + @JoinColumn(name = "loan_transaction_strategy_id") private LoanTransactionProcessingStrategy transactionProcessingStrategy; @Column(name = "name", nullable = false, unique = true) @@ -119,36 +119,36 @@ public class LoanProduct extends AbstractPersistableCustom { private boolean useBorrowerCycle; @Embedded - private LoanProductTrancheDetails loanProducTrancheDetails; + private LoanProductTrancheDetails loanProductTrancheDetails; - @Column(name = "start_date", nullable = true) + @Column(name = "start_date") private LocalDate startDate; - @Column(name = "close_date", nullable = true) + @Column(name = "close_date") private LocalDate closeDate; - @Column(name = "external_id", length = 100, nullable = true, unique = true) + @Column(name = "external_id", length = 100, unique = true) private String externalId; @OneToMany(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER) private Set borrowerCycleVariations = new HashSet<>(); - @Column(name = "overdue_days_for_npa", nullable = true) + @Column(name = "overdue_days_for_npa") private Integer overdueDaysForNPA; - @Column(name = "min_days_between_disbursal_and_first_repayment", nullable = true) + @Column(name = "min_days_between_disbursal_and_first_repayment") private Integer minimumDaysBetweenDisbursalAndFirstRepayment; - @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch = FetchType.EAGER) + @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER) private LoanProductInterestRecalculationDetails productInterestRecalculationDetails; @Column(name = "hold_guarantee_funds") private boolean holdGuaranteeFunds; - @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch = FetchType.EAGER) + @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER) private LoanProductGuaranteeDetails loanProductGuaranteeDetails; - @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true) + @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true) private LoanProductConfigurableAttributes loanConfigurableAttributes; @Column(name = "principal_threshold_for_last_installment", scale = 2, precision = 5, nullable = false) @@ -160,19 +160,19 @@ public class LoanProduct extends AbstractPersistableCustom { @Column(name = "can_define_fixed_emi_amount") private boolean canDefineInstallmentAmount; - @Column(name = "instalment_amount_in_multiples_of", nullable = true) + @Column(name = "instalment_amount_in_multiples_of") private Integer installmentAmountInMultiplesOf; @Column(name = "is_linked_to_floating_interest_rates", nullable = false) private boolean isLinkedToFloatingInterestRate; - @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch = FetchType.EAGER) + @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER) private LoanProductFloatingRates floatingRates; @Column(name = "allow_variabe_installments", nullable = false) private boolean allowVariabeInstallments; - @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch = FetchType.EAGER) + @OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER) private LoanProductVariableInstallmentConfig variableInstallmentConfig; @Column(name = "sync_expected_with_disbursement_date") @@ -181,7 +181,7 @@ public class LoanProduct extends AbstractPersistableCustom { @Column(name = "can_use_for_topup", nullable = false) private boolean canUseForTopup = false; - @Column(name = "fixed_principal_percentage_per_installment", scale = 2, precision = 5, nullable = true) + @Column(name = "fixed_principal_percentage_per_installment", scale = 2, precision = 5) private BigDecimal fixedPrincipalPercentagePerInstallment; @Column(name = "disallow_expected_disbursements", nullable = false) @@ -190,14 +190,14 @@ public class LoanProduct extends AbstractPersistableCustom { @Column(name = "allow_approved_disbursed_amounts_over_applied", nullable = false) private boolean allowApprovedDisbursedAmountsOverApplied; - @Column(name = "over_applied_calculation_type", nullable = true) + @Column(name = "over_applied_calculation_type") private String overAppliedCalculationType; - @Column(name = "over_applied_number", nullable = true) + @Column(name = "over_applied_number") private Integer overAppliedNumber; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "delinquency_bucket_id", nullable = true) + @JoinColumn(name = "delinquency_bucket_id") private DelinquencyBucket delinquencyBucket; public static LoanProduct assembleFromJson(final Fund fund, final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy, @@ -289,7 +289,7 @@ public class LoanProduct extends AbstractPersistableCustom { final Set loanProductBorrowerCycleVariations = new HashSet<>(); if (useBorrowerCycle) { - populateBorrowerCyclevariations(command, loanProductBorrowerCycleVariations); + populateBorrowerCycleVariations(command, loanProductBorrowerCycleVariations); } final boolean multiDisburseLoan = command @@ -351,24 +351,20 @@ public class LoanProduct extends AbstractPersistableCustom { final boolean syncExpectedWithDisbursementDate = command.booleanPrimitiveValueOfParameterNamed("syncExpectedWithDisbursementDate"); final boolean canUseForTopup = command.parameterExists(LoanProductConstants.CAN_USE_FOR_TOPUP) - ? command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.CAN_USE_FOR_TOPUP) - : false; + && command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.CAN_USE_FOR_TOPUP); final boolean isEqualAmortization = command.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM) - ? command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM) - : false; + && command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM); BigDecimal fixedPrincipalPercentagePerInstallment = command .bigDecimalValueOfParameterNamed(LoanProductConstants.fixedPrincipalPercentagePerInstallmentParamName); final boolean disallowExpectedDisbursements = command.parameterExists(LoanProductConstants.DISALLOW_EXPECTED_DISBURSEMENTS) - ? command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.DISALLOW_EXPECTED_DISBURSEMENTS) - : false; + && command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.DISALLOW_EXPECTED_DISBURSEMENTS); final boolean allowApprovedDisbursedAmountsOverApplied = command .parameterExists(LoanProductConstants.ALLOW_APPROVED_DISBURSED_AMOUNTS_OVER_APPLIED) - ? command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ALLOW_APPROVED_DISBURSED_AMOUNTS_OVER_APPLIED) - : false; + && command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ALLOW_APPROVED_DISBURSED_AMOUNTS_OVER_APPLIED); final String overAppliedCalculationType = command .stringValueOfParameterNamedAllowingNull(LoanProductConstants.OVER_APPLIED_CALCULATION_TYPE); @@ -403,11 +399,7 @@ public class LoanProduct extends AbstractPersistableCustom { } } - /** - * @param command - * @param loanProductBorrowerCycleVariations - */ - private static void populateBorrowerCyclevariations(final JsonCommand command, + private static void populateBorrowerCycleVariations(final JsonCommand command, final Set loanProductBorrowerCycleVariations) { assemblePrincipalVariations(command, loanProductBorrowerCycleVariations); @@ -416,39 +408,27 @@ public class LoanProduct extends AbstractPersistableCustom { assembleInterestRateVariations(command, loanProductBorrowerCycleVariations); } - /** - * @param command - * @param loanProductBorrowerCycleVariations - */ private static void assembleInterestRateVariations(final JsonCommand command, final Set loanProductBorrowerCycleVariations) { - assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.INTERESTRATE.getValue(), + assembleVariations(command, loanProductBorrowerCycleVariations, LoanProductParamType.INTERESTRATE.getValue(), LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME); } - /** - * @param command - * @param loanProductBorrowerCycleVariations - */ private static void assembleRepaymentVariations(final JsonCommand command, final Set loanProductBorrowerCycleVariations) { - assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.REPAYMENT.getValue(), + assembleVariations(command, loanProductBorrowerCycleVariations, LoanProductParamType.REPAYMENT.getValue(), LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME); } - /** - * @param command - * @param loanProductBorrowerCycleVariations - */ private static void assemblePrincipalVariations(final JsonCommand command, final Set loanProductBorrowerCycleVariations) { - assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.PRINCIPAL.getValue(), + assembleVariations(command, loanProductBorrowerCycleVariations, LoanProductParamType.PRINCIPAL.getValue(), LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME); } - private static void assembleVaritions(final JsonCommand command, + private static void assembleVariations(final JsonCommand command, final Set loanProductBorrowerCycleVariations, Integer paramType, String variationParameterName) { if (command.parameterExists(variationParameterName)) { @@ -497,11 +477,11 @@ public class LoanProduct extends AbstractPersistableCustom { private Map updateBorrowerCycleVariations(final JsonCommand command) { final Map actualChanges = new LinkedHashMap<>(20); List variationIds = fetchAllVariationIds(); - updateBorrowerCycleVaritions(command, LoanProductParamType.PRINCIPAL.getValue(), + updateBorrowerCycleVariations(command, LoanProductParamType.PRINCIPAL.getValue(), LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, actualChanges, variationIds); - updateBorrowerCycleVaritions(command, LoanProductParamType.INTERESTRATE.getValue(), + updateBorrowerCycleVariations(command, LoanProductParamType.INTERESTRATE.getValue(), LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, actualChanges, variationIds); - updateBorrowerCycleVaritions(command, LoanProductParamType.REPAYMENT.getValue(), + updateBorrowerCycleVariations(command, LoanProductParamType.REPAYMENT.getValue(), LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, actualChanges, variationIds); for (Long id : variationIds) { this.borrowerCycleVariations.remove(fetchLoanProductBorrowerCycleVariationById(id)); @@ -517,7 +497,7 @@ public class LoanProduct extends AbstractPersistableCustom { return list; } - private void updateBorrowerCycleVaritions(final JsonCommand command, Integer paramType, String variationParameterName, + private void updateBorrowerCycleVariations(final JsonCommand command, Integer paramType, String variationParameterName, final Map actualChanges, List variationIds) { if (command.parameterExists(variationParameterName)) { final JsonArray variationArray = command.arrayOfParameterNamed(variationParameterName); @@ -579,18 +559,8 @@ public class LoanProduct extends AbstractPersistableCustom { } } - private void clearVariations(LoanProductParamType paramType, boolean clearAll) { - if (clearAll) { - this.borrowerCycleVariations.clear(); - } else { - Set remove = new HashSet<>(); - for (LoanProductBorrowerCycleVariations borrowerCycleVariations : this.borrowerCycleVariations) { - if (paramType.equals(borrowerCycleVariations.getParamType())) { - remove.add(borrowerCycleVariations); - } - } - this.borrowerCycleVariations.removeAll(remove); - } + private void clearVariations() { + this.borrowerCycleVariations.clear(); } public LoanProduct() { @@ -642,13 +612,13 @@ public class LoanProduct extends AbstractPersistableCustom { this.charges = charges; } - this.isLinkedToFloatingInterestRate = isLinkedToFloatingInterestRates == null ? false : isLinkedToFloatingInterestRates; + this.isLinkedToFloatingInterestRate = isLinkedToFloatingInterestRates != null && isLinkedToFloatingInterestRates; if (isLinkedToFloatingInterestRate) { this.floatingRates = new LoanProductFloatingRates(floatingRate, this, interestRateDifferential, minDifferentialLendingRate, maxDifferentialLendingRate, defaultDifferentialLendingRate, isFloatingInterestRateCalculationAllowed); } - this.allowVariabeInstallments = isVariableInstallmentsAllowed == null ? false : isVariableInstallmentsAllowed; + this.allowVariabeInstallments = isVariableInstallmentsAllowed != null && isVariableInstallmentsAllowed; if (allowVariabeInstallments) { this.variableInstallmentConfig = new LoanProductVariableInstallmentConfig(this, minimumGapBetweenInstallments, @@ -687,7 +657,7 @@ public class LoanProduct extends AbstractPersistableCustom { loanConfigurableAttributes.updateLoanProduct(this); } - this.loanProducTrancheDetails = new LoanProductTrancheDetails(multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); + this.loanProductTrancheDetails = new LoanProductTrancheDetails(multiDisburseLoan, maxTrancheCount, outstandingLoanBalance); this.overdueDaysForNPA = overdueDaysForNPA; this.productInterestRecalculationDetails = productInterestRecalculationDetails; this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment; @@ -948,7 +918,7 @@ public class LoanProduct extends AbstractPersistableCustom { if (this.useBorrowerCycle) { actualChanges.putAll(updateBorrowerCycleVariations(command)); } else { - clearVariations(null, true); + clearVariations(); } final String dateFormatAsInput = command.dateFormat(); final String localeAsInput = command.locale(); @@ -982,7 +952,7 @@ public class LoanProduct extends AbstractPersistableCustom { actualChanges.put(accountingTypeParamName, newValue); this.externalId = newValue; } - loanProducTrancheDetails.update(command, actualChanges, localeAsInput); + loanProductTrancheDetails.update(command, actualChanges, localeAsInput); if (command.isChangeInIntegerParameterNamed(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, this.overdueDaysForNPA)) { final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME); @@ -1015,9 +985,7 @@ public class LoanProduct extends AbstractPersistableCustom { actualChanges.put(LoanProductConstants.DELINQUENCY_BUCKET_PARAM_NAME, newValue); } - /** - * Update interest recalculation settings - */ + // Update interest recalculation settings final boolean isInterestRecalculationEnabledChanged = actualChanges .containsKey(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME); @@ -1324,15 +1292,15 @@ public class LoanProduct extends AbstractPersistableCustom { } public boolean isMultiDisburseLoan() { - return this.loanProducTrancheDetails.isMultiDisburseLoan(); + return this.loanProductTrancheDetails.isMultiDisburseLoan(); } public BigDecimal outstandingLoanBalance() { - return this.loanProducTrancheDetails.outstandingLoanBalance(); + return this.loanProductTrancheDetails.outstandingLoanBalance(); } public Integer maxTrancheCount() { - return this.loanProducTrancheDetails.maxTrancheCount(); + return this.loanProductTrancheDetails.maxTrancheCount(); } public boolean isInterestRecalculationEnabled() { @@ -1398,27 +1366,28 @@ public class LoanProduct extends AbstractPersistableCustom { if (cycleVariation.getBorrowerCycleNumber().equals(cycleNumber) && cycleVariation.getValueConditionType().equals(LoanProductValueConditionType.EQUAL)) { switch (cycleVariation.getParamType()) { - case PRINCIPAL: + case PRINCIPAL -> { borrowerCycleVariations.put(LoanProductConstants.PRINCIPAL, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_PRINCIPAL, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_PRINCIPAL, cycleVariation.getMaxValue()); principalCycleUsed = cycleVariation.getBorrowerCycleNumber(); - break; - case INTERESTRATE: + } + case INTERESTRATE -> { borrowerCycleVariations.put(LoanProductConstants.INTEREST_RATE_PER_PERIOD, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_INTEREST_RATE_PER_PERIOD, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD, cycleVariation.getMaxValue()); interestCycleUsed = cycleVariation.getBorrowerCycleNumber(); - break; - case REPAYMENT: + } + case REPAYMENT -> { borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS, cycleVariation.getMaxValue()); repaymentCycleUsed = cycleVariation.getBorrowerCycleNumber(); - break; - default: - break; + } + case INVALID -> { + + } } } else if (cycleVariation.getBorrowerCycleNumber() < cycleNumber && cycleVariation.getValueConditionType().equals(LoanProductValueConditionType.GREATERTHAN)) { @@ -1588,8 +1557,8 @@ public class LoanProduct extends AbstractPersistableCustom { this.overAppliedNumber = overAppliedNumber; } - public void setLoanProducTrancheDetails(LoanProductTrancheDetails loanProducTrancheDetails) { - this.loanProducTrancheDetails = loanProducTrancheDetails; + public void setLoanProductTrancheDetails(LoanProductTrancheDetails loanProducTrancheDetails) { + this.loanProductTrancheDetails = loanProducTrancheDetails; } public DelinquencyBucket getDelinquencyBucket() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductBorrowerCycleVariations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductBorrowerCycleVariations.java index 4a04a196e..f736bfd96 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductBorrowerCycleVariations.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductBorrowerCycleVariations.java @@ -44,10 +44,10 @@ public class LoanProductBorrowerCycleVariations extends AbstractPersistableCusto @Column(name = "value_condition", nullable = false) private Integer valueConditionType; - @Column(name = "min_value", scale = 6, precision = 19, nullable = true) + @Column(name = "min_value", scale = 6, precision = 19) private BigDecimal minValue; - @Column(name = "max_value", scale = 6, precision = 19, nullable = true) + @Column(name = "max_value", scale = 6, precision = 19) private BigDecimal maxValue; @Column(name = "default_value", scale = 6, precision = 19, nullable = false) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductConfigurableAttributes.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductConfigurableAttributes.java index 1da592a7b..e3fec2f80 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductConfigurableAttributes.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductConfigurableAttributes.java @@ -23,7 +23,7 @@ import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; import javax.persistence.Table; import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; @@ -33,35 +33,35 @@ import org.apache.fineract.portfolio.loanproduct.LoanProductConstants; @Table(name = "m_product_loan_configurable_attributes") public class LoanProductConfigurableAttributes extends AbstractPersistableCustom implements Serializable { - @ManyToOne + @OneToOne @JoinColumn(name = "loan_product_id", nullable = false) private LoanProduct loanProduct; - @Column(name = "amortization_method_enum", nullable = true) + @Column(name = "amortization_method_enum") private Boolean amortizationType; - @Column(name = "interest_method_enum", nullable = true) + @Column(name = "interest_method_enum") private Boolean interestType; - @Column(name = "loan_transaction_strategy_id", nullable = true) + @Column(name = "loan_transaction_strategy_id") private Boolean transactionProcessingStrategyId; - @Column(name = "interest_calculated_in_period_enum", nullable = true) + @Column(name = "interest_calculated_in_period_enum") private Boolean interestCalculationPeriodType; - @Column(name = "arrearstolerance_amount", nullable = true) + @Column(name = "arrearstolerance_amount") private Boolean inArrearsTolerance; - @Column(name = "repay_every", nullable = true) + @Column(name = "repay_every") private Boolean repaymentEvery; - @Column(name = "moratorium", nullable = true) + @Column(name = "moratorium") private Boolean graceOnPrincipalAndInterestPayment; - @Column(name = "grace_on_arrears_ageing", nullable = true) + @Column(name = "grace_on_arrears_ageing") private Boolean graceOnArrearsAgeing; - private static final String[] supportedloanConfigurableAttributes = { LoanProductConstants.amortizationTypeParamName, + private static final String[] supportedLoanConfigurableAttributes = { LoanProductConstants.amortizationTypeParamName, LoanProductConstants.interestTypeParamName, LoanProductConstants.transactionProcessingStrategyIdParamName, LoanProductConstants.interestCalculationPeriodTypeParamName, LoanProductConstants.inArrearsToleranceParamName, LoanProductConstants.repaymentEveryParamName, LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName, @@ -134,7 +134,7 @@ public class LoanProductConfigurableAttributes extends AbstractPersistableCustom } public static String[] getAllowedLoanConfigurableAttributes() { - return supportedloanConfigurableAttributes; + return supportedLoanConfigurableAttributes; } public LoanProduct getLoanProduct() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductFloatingRates.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductFloatingRates.java index aaccf253f..61832095c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductFloatingRates.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductFloatingRates.java @@ -105,7 +105,7 @@ public class LoanProductFloatingRates extends AbstractPersistableCustom { return this.isFloatingInterestRateCalculationAllowed; } - public Map update(JsonCommand command, FloatingRate floatingRate) { + public Map update(JsonCommand command, FloatingRate floatingRate) { final Map actualChanges = new LinkedHashMap<>(20); if (floatingRate != null) { final String floatingRatesId = "floatingRatesId"; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductGuaranteeDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductGuaranteeDetails.java index 8f246a2b3..0f6216740 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductGuaranteeDetails.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductGuaranteeDetails.java @@ -46,10 +46,10 @@ public class LoanProductGuaranteeDetails extends AbstractPersistableCustom { @Column(name = "mandatory_guarantee", scale = 6, precision = 19, nullable = false) private BigDecimal mandatoryGuarantee; - @Column(name = "minimum_guarantee_from_own_funds", scale = 6, precision = 19, nullable = true) + @Column(name = "minimum_guarantee_from_own_funds", scale = 6, precision = 19) private BigDecimal minimumGuaranteeFromOwnFunds; - @Column(name = "minimum_guarantee_from_guarantor_funds", scale = 6, precision = 19, nullable = true) + @Column(name = "minimum_guarantee_from_guarantor_funds", scale = 6, precision = 19) private BigDecimal minimumGuaranteeFromGuarantor; protected LoanProductGuaranteeDetails() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java index cdfa4dae7..7c4053019 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java @@ -60,28 +60,28 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable @Column(name = "rest_frequency_interval", nullable = false) private Integer restInterval; - @Column(name = "rest_frequency_nth_day_enum", nullable = true) + @Column(name = "rest_frequency_nth_day_enum") private Integer restFrequencyNthDay; - @Column(name = "rest_frequency_weekday_enum", nullable = true) + @Column(name = "rest_frequency_weekday_enum") private Integer restFrequencyWeekday; - @Column(name = "rest_frequency_on_day", nullable = true) + @Column(name = "rest_frequency_on_day") private Integer restFrequencyOnDay; - @Column(name = "compounding_frequency_type_enum", nullable = true) + @Column(name = "compounding_frequency_type_enum") private Integer compoundingFrequencyType; - @Column(name = "compounding_frequency_interval", nullable = true) + @Column(name = "compounding_frequency_interval") private Integer compoundingInterval; - @Column(name = "compounding_frequency_nth_day_enum", nullable = true) + @Column(name = "compounding_frequency_nth_day_enum") private Integer compoundingFrequencyNthDay; - @Column(name = "compounding_frequency_weekday_enum", nullable = true) + @Column(name = "compounding_frequency_weekday_enum") private Integer compoundingFrequencyWeekday; - @Column(name = "compounding_frequency_on_day", nullable = true) + @Column(name = "compounding_frequency_on_day") private Integer compoundingFrequencyOnDay; @Column(name = "arrears_based_on_original_schedule") @@ -302,8 +302,8 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable InterestRecalculationCompoundingMethod compoundingMethod = InterestRecalculationCompoundingMethod .fromInt(this.interestRecalculationCompoundingMethod); if (compoundingMethod.isCompoundingEnabled()) { - RecalculationFrequencyType compoundingfrequencyType = RecalculationFrequencyType.fromInt(this.compoundingFrequencyType); - if (compoundingfrequencyType.isSameAsRepayment()) { + RecalculationFrequencyType compoundingFrequencyType = RecalculationFrequencyType.fromInt(this.compoundingFrequencyType); + if (compoundingFrequencyType.isSameAsRepayment()) { this.compoundingInterval = null; this.compoundingFrequencyNthDay = null; this.compoundingFrequencyWeekday = null; @@ -346,10 +346,10 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable this.compoundingFrequencyWeekday = null; } - if (compoundingfrequencyType.isWeekly()) { + if (compoundingFrequencyType.isWeekly()) { this.compoundingFrequencyNthDay = null; this.compoundingFrequencyOnDay = null; - } else if (compoundingfrequencyType.isMonthly()) { + } else if (compoundingFrequencyType.isMonthly()) { if (command .integerValueOfParameterNamed(LoanProductConstants.recalculationCompoundingFrequencyOnDayParamName) != null) { this.compoundingFrequencyNthDay = null; @@ -357,13 +357,13 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable } else { this.compoundingFrequencyOnDay = null; } - } else if (compoundingfrequencyType.isDaily()) { + } else if (compoundingFrequencyType.isDaily()) { this.compoundingFrequencyNthDay = null; this.compoundingFrequencyWeekday = null; this.compoundingFrequencyOnDay = null; } } - if (!compoundingfrequencyType.isDaily()) { + if (!compoundingFrequencyType.isDaily()) { if (command.isChangeInBooleanParameterNamed(LoanProductConstants.allowCompoundingOnEodParamName, allowCompoundingOnEod())) { boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.allowCompoundingOnEodParamName); actualChanges.put(LoanProductConstants.allowCompoundingOnEodParamName, newValue); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductMinMaxConstraints.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductMinMaxConstraints.java index 60f0515d4..70c60690f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductMinMaxConstraints.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductMinMaxConstraints.java @@ -31,22 +31,22 @@ import org.apache.fineract.infrastructure.core.api.JsonCommand; @Embeddable public class LoanProductMinMaxConstraints { - @Column(name = "min_principal_amount", scale = 6, precision = 19, nullable = true) + @Column(name = "min_principal_amount", scale = 6, precision = 19) private BigDecimal minPrincipal; - @Column(name = "max_principal_amount", scale = 6, precision = 19, nullable = true) + @Column(name = "max_principal_amount", scale = 6, precision = 19) private BigDecimal maxPrincipal; - @Column(name = "min_nominal_interest_rate_per_period", scale = 6, precision = 19, nullable = true) + @Column(name = "min_nominal_interest_rate_per_period", scale = 6, precision = 19) private BigDecimal minNominalInterestRatePerPeriod; - @Column(name = "max_nominal_interest_rate_per_period", scale = 6, precision = 19, nullable = true) + @Column(name = "max_nominal_interest_rate_per_period", scale = 6, precision = 19) private BigDecimal maxNominalInterestRatePerPeriod; - @Column(name = "min_number_of_repayments", nullable = true) + @Column(name = "min_number_of_repayments") private Integer minNumberOfRepayments; - @Column(name = "max_number_of_repayments", nullable = true) + @Column(name = "max_number_of_repayments") private Integer maxNumberOfRepayments; public static LoanProductMinMaxConstraints createFrom(final BigDecimal minPrincipal, final BigDecimal maxPrincipal, diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductParamType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductParamType.java index fd6213cd8..48ea5292f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductParamType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductParamType.java @@ -44,20 +44,12 @@ public enum LoanProductParamType { public static LoanProductParamType fromInt(final Integer chargeTime) { LoanProductParamType loanProductParamType = LoanProductParamType.INVALID; if (chargeTime != null) { - switch (chargeTime) { - case 1: - loanProductParamType = PRINCIPAL; - break; - case 2: - loanProductParamType = INTERESTRATE; - break; - case 3: - loanProductParamType = REPAYMENT; - break; - default: - loanProductParamType = INVALID; - break; - } + loanProductParamType = switch (chargeTime) { + case 1 -> PRINCIPAL; + case 2 -> INTERESTRATE; + case 3 -> REPAYMENT; + default -> INVALID; + }; } return loanProductParamType; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductRelatedDetail.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductRelatedDetail.java index 3a3dd8c57..6d2e688fd 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductRelatedDetail.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductRelatedDetail.java @@ -51,19 +51,19 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche @Embedded private MonetaryCurrency currency; - @Column(name = "principal_amount", scale = 6, precision = 19, nullable = true) + @Column(name = "principal_amount", scale = 6, precision = 19) private BigDecimal principal; - @Column(name = "nominal_interest_rate_per_period", scale = 6, precision = 19, nullable = true) + @Column(name = "nominal_interest_rate_per_period", scale = 6, precision = 19) private BigDecimal nominalInterestRatePerPeriod; // FIXME - move away form JPA ordinal use for enums using just integer - // requires sql patch for existing users of software. @Enumerated(EnumType.ORDINAL) - @Column(name = "interest_period_frequency_enum", nullable = true) + @Column(name = "interest_period_frequency_enum") private PeriodFrequencyType interestPeriodFrequencyType; - @Column(name = "annual_nominal_interest_rate", scale = 6, precision = 19, nullable = true) + @Column(name = "annual_nominal_interest_rate", scale = 6, precision = 19) private BigDecimal annualNominalInterestRate; // FIXME - move away form JPA ordinal use for enums using just integer - @@ -93,16 +93,16 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche @Column(name = "number_of_repayments", nullable = false) private Integer numberOfRepayments; - @Column(name = "grace_on_principal_periods", nullable = true) + @Column(name = "grace_on_principal_periods") private Integer graceOnPrincipalPayment; - @Column(name = "recurring_moratorium_principal_periods", nullable = true) + @Column(name = "recurring_moratorium_principal_periods") private Integer recurringMoratoriumOnPrincipalPeriods; - @Column(name = "grace_on_interest_periods", nullable = true) + @Column(name = "grace_on_interest_periods") private Integer graceOnInterestPayment; - @Column(name = "grace_interest_free_periods", nullable = true) + @Column(name = "grace_interest_free_periods") private Integer graceOnInterestCharged; // FIXME - move away form JPA ordinal use for enums using just integer - @@ -111,10 +111,10 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche @Column(name = "amortization_method_enum", nullable = false) private AmortizationMethod amortizationMethod; - @Column(name = "arrearstolerance_amount", scale = 6, precision = 19, nullable = true) + @Column(name = "arrearstolerance_amount", scale = 6, precision = 19) private BigDecimal inArrearsTolerance; - @Column(name = "grace_on_arrears_ageing", nullable = true) + @Column(name = "grace_on_arrears_ageing") private Integer graceOnArrearsAgeing; @Column(name = "days_in_month_enum", nullable = false) @@ -190,7 +190,7 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche private Integer defaultToNullIfZero(final Integer value) { Integer defaultTo = value; - if (value != null && Integer.valueOf(0).equals(value)) { + if (Integer.valueOf(0).equals(value)) { defaultTo = null; } return defaultTo; @@ -537,11 +537,11 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche int graceOnPrincipal = 0; if (this.getGraceOnPrincipalPayment() != null) { - graceOnPrincipal = this.getGraceOnPrincipalPayment().intValue(); + graceOnPrincipal = this.getGraceOnPrincipalPayment(); } int recurMoratoriumOnPrincipal = 0; if (this.recurringMoratoriumOnPrincipalPeriods() != null) { - recurMoratoriumOnPrincipal = this.recurringMoratoriumOnPrincipalPeriods().intValue(); + recurMoratoriumOnPrincipal = this.recurringMoratoriumOnPrincipalPeriods(); } if ((recurMoratoriumOnPrincipal > 0) && ((this.numberOfRepayments - graceOnPrincipal) % (recurMoratoriumOnPrincipal + 1) != 1)) { @@ -558,7 +558,7 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche private Integer defaultToZeroIfNull(final Integer value) { Integer result = value; if (value == null) { - result = Integer.valueOf(0); + result = 0; } return result; } @@ -573,7 +573,7 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche return this.currency.getCode().equalsIgnoreCase(currencyCode); } - public void updatenterestPeriodFrequencyType(final PeriodFrequencyType interestPeriodFrequencyType) { + public void updateInterestPeriodFrequencyType(final PeriodFrequencyType interestPeriodFrequencyType) { this.interestPeriodFrequencyType = interestPeriodFrequencyType; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductTrancheDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductTrancheDetails.java index 3db3f43d8..991d0c29a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductTrancheDetails.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductTrancheDetails.java @@ -31,10 +31,10 @@ public class LoanProductTrancheDetails { @Column(name = "allow_multiple_disbursals") private boolean multiDisburseLoan; - @Column(name = "max_disbursals", nullable = true) + @Column(name = "max_disbursals") private Integer maxTrancheCount; - @Column(name = "max_outstanding_loan_balance", scale = 6, precision = 19, nullable = true) + @Column(name = "max_outstanding_loan_balance", scale = 6, precision = 19) private BigDecimal outstandingLoanBalance; protected LoanProductTrancheDetails() { @@ -67,7 +67,6 @@ public class LoanProductTrancheDetails { final BigDecimal newValue = command .bigDecimalValueOfParameterNamed(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME); actualChanges.put(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME, newValue); - actualChanges.put(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME, localeAsInput); this.outstandingLoanBalance = newValue; } } else { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductValueConditionType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductValueConditionType.java index 015119771..9491eb1ab 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductValueConditionType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductValueConditionType.java @@ -44,17 +44,11 @@ public enum LoanProductValueConditionType { public static LoanProductValueConditionType fromInt(final Integer type) { LoanProductValueConditionType loanProductParamType = LoanProductValueConditionType.INVALID; if (type != null) { - switch (type) { - case 2: - loanProductParamType = EQUAL; - break; - case 3: - loanProductParamType = GREATERTHAN; - break; - default: - loanProductParamType = INVALID; - break; - } + loanProductParamType = switch (type) { + case 2 -> EQUAL; + case 3 -> GREATERTHAN; + default -> INVALID; + }; } return loanProductParamType; } @@ -63,7 +57,7 @@ public enum LoanProductValueConditionType { return LoanProductValueConditionType.EQUAL.getValue().equals(this.value); } - public boolean isValueConditionTypeGreterThan() { + public boolean isValueConditionTypeGreaterThan() { return LoanProductValueConditionType.GREATERTHAN.getValue().equals(this.value); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductVariableInstallmentConfig.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductVariableInstallmentConfig.java index 889fd9531..e69106f93 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductVariableInstallmentConfig.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductVariableInstallmentConfig.java @@ -57,7 +57,7 @@ public class LoanProductVariableInstallmentConfig extends AbstractPersistableCus this.loanProduct = loanProduct; } - public Map update(JsonCommand command) { + public Map update(JsonCommand command) { final Map actualChanges = new LinkedHashMap<>(3); if (command.isChangeInIntegerParameterNamed(LoanProductConstants.minimumGapBetweenInstallments, this.minimumGap)) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java index 4045341fa..fc3438911 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanRescheduleStrategyMethod.java @@ -48,8 +48,7 @@ public enum LoanRescheduleStrategyMethod { } public static LoanRescheduleStrategyMethod fromInt(final Integer ruleTypeValue) { - final LoanRescheduleStrategyMethod type = intToEnumMap.get(ruleTypeValue); - return type; + return intToEnumMap.get(ruleTypeValue); } LoanRescheduleStrategyMethod(final Integer value, final String code) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/RecalculationFrequencyType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/RecalculationFrequencyType.java index 13cc32404..1fd4d8389 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/RecalculationFrequencyType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/RecalculationFrequencyType.java @@ -44,8 +44,7 @@ public enum RecalculationFrequencyType { if (ruleTypeValue == null) { return RecalculationFrequencyType.INVALID; } - final RecalculationFrequencyType type = intToEnumMap.get(ruleTypeValue); - return type; + return intToEnumMap.get(ruleTypeValue); } RecalculationFrequencyType(final Integer value, final String code) { @@ -78,21 +77,11 @@ public enum RecalculationFrequencyType { } public boolean isSameFrequency(final PeriodFrequencyType frequencyType) { - boolean isSameFre = false; - switch (this) { - case DAILY: - isSameFre = frequencyType.isDaily(); - break; - case MONTHLY: - isSameFre = frequencyType.isMonthly(); - break; - case WEEKLY: - isSameFre = frequencyType.isWeekly(); - break; - default: - break; - } - - return isSameFre; + return switch (this) { + case DAILY -> frequencyType.isDaily(); + case MONTHLY -> frequencyType.isMonthly(); + case WEEKLY -> frequencyType.isWeekly(); + default -> false; + }; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/exception/InvalidLendingStrategy.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/exception/InvalidLendingStrategy.java index 285e63a39..af27fff7c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/exception/InvalidLendingStrategy.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/exception/InvalidLendingStrategy.java @@ -26,6 +26,6 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR public class InvalidLendingStrategy extends AbstractPlatformDomainRuleException { public InvalidLendingStrategy(final Integer strategyId) { - super("error.msg.unsupported.lending.strategy", "Stratagy code [" + strategyId + "] passed is not valid."); + super("error.msg.unsupported.lending.strategy", "Strategy code [" + strategyId + "] passed is not valid."); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/api/ProductMixApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/api/ProductMixApiResource.java index 3c61f1340..fed6f2154 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/api/ProductMixApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/api/ProductMixApiResource.java @@ -53,7 +53,7 @@ import org.springframework.stereotype.Component; @Path("/loanproducts/{productId}/productmix") @Component @Scope("singleton") -@Tag(name = "Product Mix", description = "") +@Tag(name = "Product Mix") public class ProductMixApiResource { private final String resourceNameForPermissions = "PRODUCTMIX"; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/serialization/ProductMixDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/serialization/ProductMixDataValidator.java index fa689f127..4d0eced5c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/serialization/ProductMixDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/serialization/ProductMixDataValidator.java @@ -22,7 +22,6 @@ import com.google.gson.JsonElement; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -42,7 +41,7 @@ public final class ProductMixDataValidator { /** * The parameters supported for this command. */ - private final Set supportedParameters = new HashSet<>(Arrays.asList("restrictedProducts")); + private final Set supportedParameters = new HashSet<>(List.of("restrictedProducts")); private final FromJsonHelper fromApiJsonHelper; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixReadPlatformServiceImpl.java index 208084f9e..ad6c90d11 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixReadPlatformServiceImpl.java @@ -60,7 +60,7 @@ public class ProductMixReadPlatformServiceImpl implements ProductMixReadPlatform final String sql = "Select " + extractor.schema() + " where pm.product_id=?"; - final Map productMixData = this.jdbcTemplate.query(sql, extractor, new Object[] { productId }); // NOSONAR + final Map productMixData = this.jdbcTemplate.query(sql, extractor, productId); // NOSONAR return productMixData.get(productId); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixWritePlatformServiceJpaRepositoryImpl.java index e4de4d191..1220ed600 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/productmix/service/ProductMixWritePlatformServiceJpaRepositoryImpl.java @@ -180,18 +180,18 @@ public class ProductMixWritePlatformServiceJpaRepositoryImpl implements ProductM private Map getRestrictedProducts(final Set restrictedIds) { - final Map restricrtedProducts = new HashMap<>(); + final Map restrictedProducts = new HashMap<>(); for (final String restrictedId : restrictedIds) { final Long restrictedIdAsLong = Long.valueOf(restrictedId); final LoanProduct restrictedProduct = findByProductIdIfProvided(Long.valueOf(restrictedId)); - restricrtedProducts.put(restrictedIdAsLong, restrictedProduct); + restrictedProducts.put(restrictedIdAsLong, restrictedProduct); } - return restricrtedProducts; + return restrictedProducts; } private void handleDataIntegrityIssues(final NonTransientDataAccessException dve) { - LOG.error("Error occured.", dve); + LOG.error("Error occurred.", dve); throw new PlatformDataIntegrityException("error.msg.product.loan.unknown.data.integrity.issue", "Unknown data integrity issue with resource."); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java index ca2b9442e..53cdcabba 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java @@ -113,7 +113,7 @@ public final class LoanProductDataValidator { LoanProductConstants.ALLOW_APPROVED_DISBURSED_AMOUNTS_OVER_APPLIED, LoanProductConstants.OVER_APPLIED_CALCULATION_TYPE, LoanProductConstants.OVER_APPLIED_NUMBER, LoanProductConstants.DELINQUENCY_BUCKET_PARAM_NAME)); - private static final String[] supportedloanConfigurableAttributes = { LoanProductConstants.amortizationTypeParamName, + private static final String[] supportedLoanConfigurableAttributes = { LoanProductConstants.amortizationTypeParamName, LoanProductConstants.interestTypeParamName, LoanProductConstants.transactionProcessingStrategyIdParamName, LoanProductConstants.interestCalculationPeriodTypeParamName, LoanProductConstants.inArrearsToleranceParamName, LoanProductConstants.repaymentEveryParamName, LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName, @@ -301,17 +301,11 @@ public final class LoanProductDataValidator { baseDataValidator.reset().parameter(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME).value(overdueDaysForNPA) .integerZeroOrGreater(); - /** - * { @link DaysInYearType } - */ final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, element, Locale.getDefault()); baseDataValidator.reset().parameter(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME).value(daysInYearType).notNull() .isOneOfTheseValues(1, 360, 364, 365); - /** - * { @link DaysInMonthType } - */ final Integer daysInMonthType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME, element, Locale.getDefault()); baseDataValidator.reset().parameter(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME).value(daysInMonthType).notNull() @@ -342,7 +336,7 @@ public final class LoanProductDataValidator { // interest rates if (this.fromApiJsonHelper.parameterExists("isLinkedToFloatingInterestRates", element) - && this.fromApiJsonHelper.extractBooleanNamed("isLinkedToFloatingInterestRates", element) == true) { + && this.fromApiJsonHelper.extractBooleanNamed("isLinkedToFloatingInterestRates", element)) { if (isEqualAmortization) { throw new EqualAmortizationUnsupportedFeatureException("floating.interest.rate", "floating interest rate"); } @@ -370,7 +364,7 @@ public final class LoanProductDataValidator { "interestRateFrequencyType param is not supported when isLinkedToFloatingInterestRates is true"); } if ((interestType == null || !interestType.equals(InterestMethod.DECLINING_BALANCE.getValue())) - || (isInterestRecalculationEnabled == null || isInterestRecalculationEnabled == false)) { + || (isInterestRecalculationEnabled == null || !isInterestRecalculationEnabled)) { baseDataValidator.reset().parameter("isLinkedToFloatingInterestRates").failWithCode( "supported.only.for.declining.balance.interest.recalculation.enabled", "Floating interest rates are supported only for declining balance and interest recalculation enabled loan products"); @@ -713,17 +707,15 @@ public final class LoanProductDataValidator { // Validate that parameter names are allowed Set supportedConfigurableAttributes = new HashSet<>(); - Collections.addAll(supportedConfigurableAttributes, supportedloanConfigurableAttributes); + Collections.addAll(supportedConfigurableAttributes, supportedLoanConfigurableAttributes); this.fromApiJsonHelper.checkForUnsupportedNestedParameters(LoanProductConstants.allowAttributeOverridesParamName, object, supportedConfigurableAttributes); - Integer length = supportedloanConfigurableAttributes.length; - - for (int i = 0; i < length; i++) { + for (String supportedLoanConfigurableAttribute : supportedLoanConfigurableAttributes) { /* Validate the attribute names */ - if (this.fromApiJsonHelper.parameterExists(supportedloanConfigurableAttributes[i], object)) { - Boolean loanConfigurationAttributeValue = this.fromApiJsonHelper - .extractBooleanNamed(supportedloanConfigurableAttributes[i], object); + if (this.fromApiJsonHelper.parameterExists(supportedLoanConfigurableAttribute, object)) { + Boolean loanConfigurationAttributeValue = this.fromApiJsonHelper.extractBooleanNamed(supportedLoanConfigurableAttribute, + object); /* Validate the boolean value */ baseDataValidator.reset().parameter(LoanProductConstants.allowAttributeOverridesParamName) .value(loanConfigurationAttributeValue).notNull().validateForBooleanValue(); @@ -775,9 +767,6 @@ public final class LoanProductDataValidator { private void validateInterestRecalculationParams(final JsonElement element, final DataValidatorBuilder baseDataValidator, final LoanProduct loanProduct) { - /** - * { @link InterestRecalculationCompoundingMethod } - */ InterestRecalculationCompoundingMethod compoundingMethod = null; if (loanProduct == null || this.fromApiJsonHelper @@ -800,9 +789,6 @@ public final class LoanProductDataValidator { } } - /** - * { @link LoanRescheduleStrategyMethod } - */ if (loanProduct == null || this.fromApiJsonHelper.parameterExists(LoanProductConstants.rescheduleStrategyMethodParameterName, element)) { final Integer rescheduleStrategyMethod = this.fromApiJsonHelper @@ -857,7 +843,7 @@ public final class LoanProductDataValidator { } if (compoundingMethod.isCompoundingEnabled()) { - RecalculationFrequencyType compoundingfrequencyType = null; + RecalculationFrequencyType compoundingFrequencyType = null; if (loanProduct == null || this.fromApiJsonHelper .parameterExists(LoanProductConstants.recalculationCompoundingFrequencyTypeParameterName, element)) { @@ -866,8 +852,8 @@ public final class LoanProductDataValidator { baseDataValidator.reset().parameter(LoanProductConstants.recalculationCompoundingFrequencyTypeParameterName) .value(recalculationCompoundingFrequencyType).notNull().inMinMaxRange(1, 4); if (recalculationCompoundingFrequencyType != null) { - compoundingfrequencyType = RecalculationFrequencyType.fromInt(recalculationCompoundingFrequencyType); - if (!compoundingfrequencyType.isSameAsRepayment()) { + compoundingFrequencyType = RecalculationFrequencyType.fromInt(recalculationCompoundingFrequencyType); + if (!compoundingFrequencyType.isSameAsRepayment()) { PeriodFrequencyType repaymentFrequencyType = null; if (this.fromApiJsonHelper.parameterExists("repaymentFrequencyType", element)) { Integer repaymentFrequencyTypeVal = this.fromApiJsonHelper.extractIntegerNamed("repaymentFrequencyType", @@ -876,7 +862,7 @@ public final class LoanProductDataValidator { } else if (loanProduct != null) { repaymentFrequencyType = loanProduct.getLoanProductRelatedDetail().getRepaymentPeriodFrequencyType(); } - if (!compoundingfrequencyType.isSameFrequency(repaymentFrequencyType)) { + if (!compoundingFrequencyType.isSameFrequency(repaymentFrequencyType)) { baseDataValidator.reset().parameter(LoanProductConstants.recalculationCompoundingFrequencyTypeParameterName) .value(recalculationCompoundingFrequencyType).failWithCode("must.be.same.as.repayment.frequency"); } @@ -884,15 +870,15 @@ public final class LoanProductDataValidator { } } - if (compoundingfrequencyType == null) { + if (compoundingFrequencyType == null) { if (loanProduct == null) { - compoundingfrequencyType = RecalculationFrequencyType.INVALID; + compoundingFrequencyType = RecalculationFrequencyType.INVALID; } else { - compoundingfrequencyType = loanProduct.getProductInterestRecalculationDetails().getCompoundingFrequencyType(); + compoundingFrequencyType = loanProduct.getProductInterestRecalculationDetails().getCompoundingFrequencyType(); } } - if (!compoundingfrequencyType.isSameAsRepayment()) { + if (!compoundingFrequencyType.isSameAsRepayment()) { if (loanProduct == null || this.fromApiJsonHelper .parameterExists(LoanProductConstants.recalculationCompoundingFrequencyIntervalParameterName, element)) { final Integer recurrenceInterval = this.fromApiJsonHelper.extractIntegerNamed( @@ -1119,9 +1105,6 @@ public final class LoanProductDataValidator { .inMinMaxRange(0, 1); } - /** - * { @link DaysInYearType } - */ if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, element)) { final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, element, Locale.getDefault()); @@ -1129,9 +1112,6 @@ public final class LoanProductDataValidator { .isOneOfTheseValues(1, 360, 364, 365); } - /** - * { @link DaysInMonthType } - */ if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, element)) { final Integer daysInMonthType = this.fromApiJsonHelper .extractIntegerNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME, element, Locale.getDefault()); @@ -1209,7 +1189,7 @@ public final class LoanProductDataValidator { ? this.fromApiJsonHelper.extractIntegerNamed("interestType", element, Locale.getDefault()) : loanProduct.getLoanProductRelatedDetail().getInterestMethod().getValue(); if ((interestType == null || !interestType.equals(InterestMethod.DECLINING_BALANCE.getValue())) - || (isInterestRecalculationEnabled == null || isInterestRecalculationEnabled == false)) { + || (isInterestRecalculationEnabled == null || !isInterestRecalculationEnabled)) { baseDataValidator.reset().parameter("isLinkedToFloatingInterestRates").failWithCode( "supported.only.for.declining.balance.interest.recalculation.enabled", "Floating interest rates are supported only for declining balance and interest recalculation enabled loan products"); @@ -1534,6 +1514,7 @@ public final class LoanProductDataValidator { private void validateChargeToIncomeAccountMappings(final DataValidatorBuilder baseDataValidator, final JsonElement element) { // validate for both fee and penalty charges + // TODO: This look faulty. Need to analyze this behaviour before changing validateChargeToIncomeAccountMappings(baseDataValidator, element, true); validateChargeToIncomeAccountMappings(baseDataValidator, element, true); } @@ -1776,7 +1757,7 @@ public final class LoanProductDataValidator { final DataValidatorBuilder baseDataValidator) { if ((this.fromApiJsonHelper.parameterExists("isLinkedToFloatingInterestRates", element) - && this.fromApiJsonHelper.extractBooleanNamed("isLinkedToFloatingInterestRates", element) == true) + && this.fromApiJsonHelper.extractBooleanNamed("isLinkedToFloatingInterestRates", element)) || loanProduct.isLinkedToFloatingInterestRate()) { return; } @@ -1901,7 +1882,7 @@ public final class LoanProductDataValidator { final String maxParameterName, final String valueUsageConditionParamName, final String cycleNumbersParamName) { final JsonObject topLevelJsonElement = element.getAsJsonObject(); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); - Integer lastCycleNumber = 0; + int lastCycleNumber = 0; LoanProductValueConditionType lastConditionType = LoanProductValueConditionType.EQUAL; if (this.fromApiJsonHelper.parameterExists(variationParameterName, element)) { final JsonArray variationArray = this.fromApiJsonHelper.extractJsonArrayNamed(variationParameterName, element); @@ -2021,7 +2002,7 @@ public final class LoanProductDataValidator { if (mandatoryGuarantee.compareTo(minimumGuaranteeFromOwnFunds.add(minimumGuaranteeFromGuarantor)) < 0) { baseDataValidator.parameter(LoanProductConstants.mandatoryGuaranteeParamName) - .failWithCode("must.be.greter.than.sum.of.min.funds"); + .failWithCode("must.be.greater.than.sum.of.min.funds"); } } @@ -2039,11 +2020,11 @@ public final class LoanProductDataValidator { .extractBooleanNamed(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, element); baseDataValidator.reset().parameter(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME) .value(considerPartialInterestEnabled).notNull().isOneOfTheseValues(true, false); - final boolean considerPartialPeriods = considerPartialInterestEnabled == null ? false : considerPartialInterestEnabled; + final boolean considerPartialPeriods = considerPartialInterestEnabled != null && considerPartialInterestEnabled; if (interestCalculationPeriodMethod.isDaily()) { if (considerPartialPeriods) { baseDataValidator.reset().parameter(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME) - .failWithCode("not.supported.for.daily.calcualtions"); + .failWithCode("not.supported.for.daily.calculations"); } } else { considerPartialPeriodUpdates = considerPartialPeriods; @@ -2061,7 +2042,7 @@ public final class LoanProductDataValidator { } if (isInterestRecalculationEnabled != null && isInterestRecalculationEnabled) { baseDataValidator.reset().parameter(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME) - .failWithCode("not.supported.for.selected.interest.calcualtion.type"); + .failWithCode("not.supported.for.selected.interest.calculation.type"); } Boolean multiDisburseLoan = null; @@ -2073,7 +2054,7 @@ public final class LoanProductDataValidator { } if (multiDisburseLoan != null && multiDisburseLoan) { baseDataValidator.reset().parameter(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME) - .failWithCode("not.supported.for.selected.interest.calcualtion.type"); + .failWithCode("not.supported.for.selected.interest.calculation.type"); } Boolean variableInstallments = null; @@ -2085,7 +2066,7 @@ public final class LoanProductDataValidator { } if (variableInstallments != null && variableInstallments) { baseDataValidator.reset().parameter(LoanProductConstants.allowVariableInstallmentsParamName) - .failWithCode("not.supported.for.selected.interest.calcualtion.type"); + .failWithCode("not.supported.for.selected.interest.calculation.type"); } Boolean floatingInterestRates = null; @@ -2096,7 +2077,7 @@ public final class LoanProductDataValidator { } if (floatingInterestRates != null && floatingInterestRates) { baseDataValidator.reset().parameter("isLinkedToFloatingInterestRates") - .failWithCode("not.supported.for.selected.interest.calcualtion.type"); + .failWithCode("not.supported.for.selected.interest.calculation.type"); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LendingStrategyEnumerations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LendingStrategyEnumerations.java index ae9983976..9d0716042 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LendingStrategyEnumerations.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LendingStrategyEnumerations.java @@ -32,27 +32,13 @@ public final class LendingStrategyEnumerations { } public static EnumOptionData lendingStrategy(final LendingStrategy type) { - EnumOptionData optionData = null; - switch (type) { - case INDIVIDUAL_LOAN: - optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Individual loan"); - break; - case GROUP_LOAN: - optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Group loan"); - break; - case JOINT_LIABILITY_LOAN: - optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Joint liability loan"); - break; - case LINKED_LOAN: - optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Linked loan"); - break; - - default: - optionData = new EnumOptionData(LendingStrategy.INVALID.getId().longValue(), LendingStrategy.INVALID.getCode(), "Invalid"); - break; - - } - return optionData; + return switch (type) { + case INDIVIDUAL_LOAN -> new EnumOptionData(type.getId().longValue(), type.getCode(), "Individual loan"); + case GROUP_LOAN -> new EnumOptionData(type.getId().longValue(), type.getCode(), "Group loan"); + case JOINT_LIABILITY_LOAN -> new EnumOptionData(type.getId().longValue(), type.getCode(), "Joint liability loan"); + case LINKED_LOAN -> new EnumOptionData(type.getId().longValue(), type.getCode(), "Linked loan"); + default -> new EnumOptionData(LendingStrategy.INVALID.getId().longValue(), LendingStrategy.INVALID.getCode(), "Invalid"); + }; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java index 4a4ad1c8a..c07784a97 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java @@ -41,7 +41,7 @@ public interface LoanDropdownReadPlatformService { List retrieveInterestRateFrequencyTypeOptions(); - Collection retreiveTransactionProcessingStrategies(); + Collection retrieveTransactionProcessingStrategies(); List retrieveLoanCycleValueConditionTypeOptions(); @@ -55,6 +55,6 @@ public interface LoanDropdownReadPlatformService { List retrieveInterestRecalculationFrequencyTypeOptions(); - List retrivePreCloseInterestCalculationStrategyOptions(); + List retrievePreCloseInterestCalculationStrategyOptions(); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java index ef788c6e4..4cb3b5833 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java @@ -71,73 +71,60 @@ public class LoanDropdownReadPlatformServiceImpl implements LoanDropdownReadPlat @Override public List retrieveLoanAmortizationTypeOptions() { - final List allowedAmortizationMethods = Arrays.asList(amortizationType(AmortizationMethod.EQUAL_INSTALLMENTS), - amortizationType(AmortizationMethod.EQUAL_PRINCIPAL)); - - return allowedAmortizationMethods; + return Arrays.asList(amortizationType(AmortizationMethod.EQUAL_INSTALLMENTS), amortizationType(AmortizationMethod.EQUAL_PRINCIPAL)); } @Override public List retrieveLoanInterestTypeOptions() { - final List allowedRepaymentScheduleCalculationMethods = Arrays.asList(interestType(InterestMethod.FLAT), - interestType(InterestMethod.DECLINING_BALANCE)); - return allowedRepaymentScheduleCalculationMethods; + return Arrays.asList(interestType(InterestMethod.FLAT), interestType(InterestMethod.DECLINING_BALANCE)); } @Override public List retrieveLoanInterestRateCalculatedInPeriodOptions() { - final List allowedOptions = Arrays.asList(interestCalculationPeriodType(InterestCalculationPeriodMethod.DAILY), + return Arrays.asList(interestCalculationPeriodType(InterestCalculationPeriodMethod.DAILY), interestCalculationPeriodType(InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD)); - - return allowedOptions; } @Override public List retrieveLoanTermFrequencyTypeOptions() { - final List loanTermFrequencyOptions = Arrays.asList(loanTermFrequencyType(PeriodFrequencyType.DAYS), - loanTermFrequencyType(PeriodFrequencyType.WEEKS), loanTermFrequencyType(PeriodFrequencyType.MONTHS), - loanTermFrequencyType(PeriodFrequencyType.YEARS)); - return loanTermFrequencyOptions; + return Arrays.asList(loanTermFrequencyType(PeriodFrequencyType.DAYS), loanTermFrequencyType(PeriodFrequencyType.WEEKS), + loanTermFrequencyType(PeriodFrequencyType.MONTHS), loanTermFrequencyType(PeriodFrequencyType.YEARS)); } @Override public List retrieveRepaymentFrequencyTypeOptions() { - final List repaymentFrequencyOptions = Arrays.asList(repaymentFrequencyType(PeriodFrequencyType.DAYS), - repaymentFrequencyType(PeriodFrequencyType.WEEKS), repaymentFrequencyType(PeriodFrequencyType.MONTHS)); - return repaymentFrequencyOptions; + return Arrays.asList(repaymentFrequencyType(PeriodFrequencyType.DAYS), repaymentFrequencyType(PeriodFrequencyType.WEEKS), + repaymentFrequencyType(PeriodFrequencyType.MONTHS)); } @Override public List retrieveRepaymentFrequencyOptionsForNthDayOfMonth() { - final List repaymentFrequencyOptions = Arrays.asList(repaymentFrequencyNthDayType(NthDayType.ONE), - repaymentFrequencyNthDayType(NthDayType.TWO), repaymentFrequencyNthDayType(NthDayType.THREE), - repaymentFrequencyNthDayType(NthDayType.FOUR), repaymentFrequencyNthDayType(NthDayType.LAST)); - return repaymentFrequencyOptions; + return Arrays.asList(repaymentFrequencyNthDayType(NthDayType.ONE), repaymentFrequencyNthDayType(NthDayType.TWO), + repaymentFrequencyNthDayType(NthDayType.THREE), repaymentFrequencyNthDayType(NthDayType.FOUR), + repaymentFrequencyNthDayType(NthDayType.LAST)); } @Override public List retrieveRepaymentFrequencyOptionsForDaysOfWeek() { - final List repaymentFrequencyOptions = Arrays.asList(repaymentFrequencyDayOfWeekType(DayOfWeekType.SUNDAY), - repaymentFrequencyDayOfWeekType(DayOfWeekType.MONDAY), repaymentFrequencyDayOfWeekType(DayOfWeekType.TUESDAY), - repaymentFrequencyDayOfWeekType(DayOfWeekType.WEDNESDAY), repaymentFrequencyDayOfWeekType(DayOfWeekType.THURSDAY), - repaymentFrequencyDayOfWeekType(DayOfWeekType.FRIDAY), repaymentFrequencyDayOfWeekType(DayOfWeekType.SATURDAY)); - return repaymentFrequencyOptions; + return Arrays.asList(repaymentFrequencyDayOfWeekType(DayOfWeekType.SUNDAY), repaymentFrequencyDayOfWeekType(DayOfWeekType.MONDAY), + repaymentFrequencyDayOfWeekType(DayOfWeekType.TUESDAY), repaymentFrequencyDayOfWeekType(DayOfWeekType.WEDNESDAY), + repaymentFrequencyDayOfWeekType(DayOfWeekType.THURSDAY), repaymentFrequencyDayOfWeekType(DayOfWeekType.FRIDAY), + repaymentFrequencyDayOfWeekType(DayOfWeekType.SATURDAY)); } @Override public List retrieveInterestRateFrequencyTypeOptions() { // support for monthly and annual percentage rate (MPR) and (APR) - final List interestRateFrequencyTypeOptions = Arrays.asList(interestRateFrequencyType(PeriodFrequencyType.MONTHS), - interestRateFrequencyType(PeriodFrequencyType.YEARS), interestRateFrequencyType(PeriodFrequencyType.WHOLE_TERM)); - return interestRateFrequencyTypeOptions; + return Arrays.asList(interestRateFrequencyType(PeriodFrequencyType.MONTHS), interestRateFrequencyType(PeriodFrequencyType.YEARS), + interestRateFrequencyType(PeriodFrequencyType.WHOLE_TERM)); } @Override - public Collection retreiveTransactionProcessingStrategies() { + public Collection retrieveTransactionProcessingStrategies() { final Collection strategyOptions = new ArrayList<>(); Sort sort = Sort.by("sortOrder"); @@ -152,72 +139,58 @@ public class LoanDropdownReadPlatformServiceImpl implements LoanDropdownReadPlat @Override public List retrieveLoanCycleValueConditionTypeOptions() { - final List repaymentFrequencyOptions = Arrays.asList( - loanCycleValueConditionType(LoanProductValueConditionType.EQUAL), + return Arrays.asList(loanCycleValueConditionType(LoanProductValueConditionType.EQUAL), loanCycleValueConditionType(LoanProductValueConditionType.GREATERTHAN)); - return repaymentFrequencyOptions; } @Override public List retrieveInterestRecalculationCompoundingTypeOptions() { - final List interestRecalculationCompoundingTypeOptions = Arrays.asList( - interestRecalculationCompoundingType(InterestRecalculationCompoundingMethod.NONE), + return Arrays.asList(interestRecalculationCompoundingType(InterestRecalculationCompoundingMethod.NONE), interestRecalculationCompoundingType(InterestRecalculationCompoundingMethod.FEE), interestRecalculationCompoundingType(InterestRecalculationCompoundingMethod.INTEREST), interestRecalculationCompoundingType(InterestRecalculationCompoundingMethod.INTEREST_AND_FEE)); - return interestRecalculationCompoundingTypeOptions; } @Override public List retrieveInterestRecalculationNthDayTypeOptions() { - final List interestRecalculationCompoundingNthDayTypeOptions = Arrays.asList( - interestRecalculationCompoundingNthDayType(NthDayType.ONE), interestRecalculationCompoundingNthDayType(NthDayType.TWO), - interestRecalculationCompoundingNthDayType(NthDayType.THREE), interestRecalculationCompoundingNthDayType(NthDayType.FOUR), - interestRecalculationCompoundingNthDayType(NthDayType.LAST)); - return interestRecalculationCompoundingNthDayTypeOptions; + return Arrays.asList(interestRecalculationCompoundingNthDayType(NthDayType.ONE), + interestRecalculationCompoundingNthDayType(NthDayType.TWO), interestRecalculationCompoundingNthDayType(NthDayType.THREE), + interestRecalculationCompoundingNthDayType(NthDayType.FOUR), interestRecalculationCompoundingNthDayType(NthDayType.LAST)); } @Override public List retrieveInterestRecalculationDayOfWeekTypeOptions() { - final List interestRecalculationCompoundingNthDayTypeOptions = Arrays.asList( - interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.SUNDAY), + return Arrays.asList(interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.SUNDAY), interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.MONDAY), interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.TUESDAY), interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.WEDNESDAY), interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.THURSDAY), interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.FRIDAY), interestRecalculationCompoundingDayOfWeekType(DayOfWeekType.SATURDAY)); - return interestRecalculationCompoundingNthDayTypeOptions; } @Override public List retrieveRescheduleStrategyTypeOptions() { - final List rescheduleStrategyTypeOptions = Arrays.asList( - rescheduleStrategyType(LoanRescheduleStrategyMethod.REDUCE_EMI_AMOUNT), + return Arrays.asList(rescheduleStrategyType(LoanRescheduleStrategyMethod.REDUCE_EMI_AMOUNT), rescheduleStrategyType(LoanRescheduleStrategyMethod.REDUCE_NUMBER_OF_INSTALLMENTS), rescheduleStrategyType(LoanRescheduleStrategyMethod.RESCHEDULE_NEXT_REPAYMENTS)); - return rescheduleStrategyTypeOptions; } @Override public List retrieveInterestRecalculationFrequencyTypeOptions() { - final List interestRecalculationFrequencyTypeOptions = Arrays.asList( - interestRecalculationFrequencyType(RecalculationFrequencyType.SAME_AS_REPAYMENT_PERIOD), + return Arrays.asList(interestRecalculationFrequencyType(RecalculationFrequencyType.SAME_AS_REPAYMENT_PERIOD), interestRecalculationFrequencyType(RecalculationFrequencyType.DAILY), interestRecalculationFrequencyType(RecalculationFrequencyType.WEEKLY), interestRecalculationFrequencyType(RecalculationFrequencyType.MONTHLY)); - return interestRecalculationFrequencyTypeOptions; } @Override - public List retrivePreCloseInterestCalculationStrategyOptions() { + public List retrievePreCloseInterestCalculationStrategyOptions() { - final List preCloseInterestCalculationStrategyOptions = Arrays.asList( - preCloseInterestCalculationStrategy(LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE), + return Arrays.asList(preCloseInterestCalculationStrategy(LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE), preCloseInterestCalculationStrategy(LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE)); - return preCloseInterestCalculationStrategyOptions; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java index fd3328d3b..92fa5df95 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java @@ -58,31 +58,21 @@ public final class LoanEnumerations { public static final String INTEREST_RECALCULATION_COMPOUNDING_TYPE = "interestRecalculationCompoundingType"; public static final String RESCHEDULE_STRATEGY_TYPE = "rescheduleStrategyType"; - public static EnumOptionData loanEnumueration(final String typeName, final int id) { - if (typeName.equals(LOAN_TERM_FREQUENCY_TYPE)) { - return loanTermFrequencyType(id); - } else if (typeName.equals(TERM_FREQUENCY_TYPE)) { - return termFrequencyType(id); - } else if (typeName.equals(REPAYMENT_FREQUENCY_TYPE)) { - return repaymentFrequencyType(id); - } else if (typeName.equals(INTEREST_RATE_FREQUENCY_TYPE)) { - return interestRateFrequencyType(id); - } else if (typeName.equals(AMORTIZATION_TYPE)) { - return amortizationType(id); - } else if (typeName.equals(INTEREST_TYPE)) { - return interestType(id); - } else if (typeName.equals(INTEREST_CALCULATION_PERIOD_TYPE)) { - return interestCalculationPeriodType(id); - } else if (typeName.equals(ACCOUNTING_RULE_TYPE)) { - return AccountingEnumerations.accountingRuleType(id); - } else if (typeName.equals(LOAN_TYPE)) { - return AccountEnumerations.loanType(id); - } else if (typeName.equals(INTEREST_RECALCULATION_COMPOUNDING_TYPE)) { - return interestRecalculationCompoundingType(id); - } else if (typeName.equals(RESCHEDULE_STRATEGY_TYPE)) { - return rescheduleStrategyType(id); - } - return null; + public static EnumOptionData loanEnumeration(final String typeName, final int id) { + return switch (typeName) { + case LOAN_TERM_FREQUENCY_TYPE -> loanTermFrequencyType(id); + case TERM_FREQUENCY_TYPE -> termFrequencyType(id); + case REPAYMENT_FREQUENCY_TYPE -> repaymentFrequencyType(id); + case INTEREST_RATE_FREQUENCY_TYPE -> interestRateFrequencyType(id); + case AMORTIZATION_TYPE -> amortizationType(id); + case INTEREST_TYPE -> interestType(id); + case INTEREST_CALCULATION_PERIOD_TYPE -> interestCalculationPeriodType(id); + case ACCOUNTING_RULE_TYPE -> AccountingEnumerations.accountingRuleType(id); + case LOAN_TYPE -> AccountEnumerations.loanType(id); + case INTEREST_RECALCULATION_COMPOUNDING_TYPE -> interestRecalculationCompoundingType(id); + case RESCHEDULE_STRATEGY_TYPE -> rescheduleStrategyType(id); + default -> null; + }; } public static EnumOptionData loanTermFrequencyType(final int id) { @@ -91,30 +81,18 @@ public final class LoanEnumerations { public static EnumOptionData loanTermFrequencyType(final PeriodFrequencyType type) { final String codePrefix = "loanTermFrequency."; - EnumOptionData optionData = null; - switch (type) { - case DAYS: - optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), - codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days"); - break; - case WEEKS: - optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), - codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks"); - break; - case MONTHS: - optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), - codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months"); - break; - case YEARS: - optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), - codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years"); - break; - default: - optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), - "Invalid"); - break; - } - return optionData; + return switch (type) { + case DAYS -> new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), + codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days"); + case WEEKS -> new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), + codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks"); + case MONTHS -> new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), + codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months"); + case YEARS -> new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), + codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years"); + default -> new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), + "Invalid"); + }; } public static EnumOptionData termFrequencyType(final int id) { @@ -123,30 +101,18 @@ public final class LoanEnumerations { public static EnumOptionData termFrequencyType(final PeriodFrequencyType type) { final String codePrefix = "termFrequency."; - EnumOptionData optionData = null; - switch (type) { - case DAYS: - optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), - codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days"); - break; - case WEEKS: - optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), - codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks"); - break; - case MONTHS: - optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), - codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months"); - break; - case YEARS: - optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), - codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years"); - break; - default: - optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), - "Invalid"); - break; - } - return optionData; + return switch (type) { + case DAYS -> new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), + codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days"); + case WEEKS -> new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), + codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks"); + case MONTHS -> new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), + codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months"); + case YEARS -> new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), + codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years"); + default -> new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), + "Invalid"); + }; } public static EnumOptionData repaymentFrequencyType(final int id) { @@ -163,32 +129,16 @@ public final class LoanEnumerations { public static EnumOptionData repaymentFrequencyNthDayType(final NthDayType type) { final String codePrefix = "repaymentFrequency."; long nthDayValue = type.getValue().longValue(); - EnumOptionData optionData = null; - switch (type) { - case ONE: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "first"); - break; - case TWO: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "second"); - break; - case THREE: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "third"); - break; - case FOUR: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fourth"); - break; - case FIVE: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fifth"); - break; - case LAST: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "last"); - break; - default: - optionData = new EnumOptionData(Integer.valueOf(0).longValue(), codePrefix + type.getCode(), "invalid"); - break; - } - return optionData; + return switch (type) { + case ONE -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "first"); + case TWO -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "second"); + case THREE -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "third"); + case FOUR -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fourth"); + case FIVE -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fifth"); + case LAST -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "last"); + default -> new EnumOptionData(Integer.valueOf(0).longValue(), codePrefix + type.getCode(), "invalid"); + }; } public static EnumOptionData repaymentFrequencyDayOfWeekType(final Integer id) { @@ -200,37 +150,24 @@ public final class LoanEnumerations { public static EnumOptionData repaymentFrequencyDayOfWeekType(final DayOfWeekType type) { final String codePrefix = "repaymentFrequency."; - EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), codePrefix + type.getCode(), type.toString()); - return optionData; + return new EnumOptionData(type.getValue().longValue(), codePrefix + type.getCode(), type.toString()); } public static EnumOptionData repaymentFrequencyType(final PeriodFrequencyType type) { final String codePrefix = "repaymentFrequency."; - EnumOptionData optionData = null; - switch (type) { - case DAYS: - optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), - codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days"); - break; - case WEEKS: - optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), - codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks"); - break; - case MONTHS: - optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), - codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months"); - break; - case YEARS: - optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), - codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years"); - break; - default: - optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), - "Invalid"); - break; - } - return optionData; + return switch (type) { + case DAYS -> new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), + codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days"); + case WEEKS -> new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), + codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks"); + case MONTHS -> new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), + codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months"); + case YEARS -> new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), + codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years"); + default -> new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), + "Invalid"); + }; } public static EnumOptionData interestRateFrequencyType(final Integer id) { @@ -239,26 +176,16 @@ public final class LoanEnumerations { public static EnumOptionData interestRateFrequencyType(final PeriodFrequencyType type) { final String codePrefix = "interestRateFrequency."; - EnumOptionData optionData = null; - switch (type) { - case MONTHS: - optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), - codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Per month"); - break; - case YEARS: - optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), - codePrefix + PeriodFrequencyType.YEARS.getCode(), "Per year"); - break; - case WHOLE_TERM: - optionData = new EnumOptionData(PeriodFrequencyType.WHOLE_TERM.getValue().longValue(), - codePrefix + PeriodFrequencyType.WHOLE_TERM.getCode(), "Whole term"); - break; - default: - optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), - "Invalid"); - break; - } - return optionData; + return switch (type) { + case MONTHS -> new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), + codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Per month"); + case YEARS -> new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), + codePrefix + PeriodFrequencyType.YEARS.getCode(), "Per year"); + case WHOLE_TERM -> new EnumOptionData(PeriodFrequencyType.WHOLE_TERM.getValue().longValue(), + codePrefix + PeriodFrequencyType.WHOLE_TERM.getCode(), "Whole term"); + default -> new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), + "Invalid"); + }; } public static EnumOptionData amortizationType(final Integer id) { @@ -266,22 +193,14 @@ public final class LoanEnumerations { } public static EnumOptionData amortizationType(final AmortizationMethod amortizationMethod) { - EnumOptionData optionData = null; - switch (amortizationMethod) { - case EQUAL_INSTALLMENTS: - optionData = new EnumOptionData(AmortizationMethod.EQUAL_INSTALLMENTS.getValue().longValue(), - AmortizationMethod.EQUAL_INSTALLMENTS.getCode(), "Equal installments"); - break; - case EQUAL_PRINCIPAL: - optionData = new EnumOptionData(AmortizationMethod.EQUAL_PRINCIPAL.getValue().longValue(), - AmortizationMethod.EQUAL_PRINCIPAL.getCode(), "Equal principal payments"); - break; - default: - optionData = new EnumOptionData(AmortizationMethod.INVALID.getValue().longValue(), AmortizationMethod.INVALID.getCode(), - "Invalid"); - break; - } - return optionData; + return switch (amortizationMethod) { + case EQUAL_INSTALLMENTS -> new EnumOptionData(AmortizationMethod.EQUAL_INSTALLMENTS.getValue().longValue(), + AmortizationMethod.EQUAL_INSTALLMENTS.getCode(), "Equal installments"); + case EQUAL_PRINCIPAL -> new EnumOptionData(AmortizationMethod.EQUAL_PRINCIPAL.getValue().longValue(), + AmortizationMethod.EQUAL_PRINCIPAL.getCode(), "Equal principal payments"); + default -> new EnumOptionData(AmortizationMethod.INVALID.getValue().longValue(), AmortizationMethod.INVALID.getCode(), + "Invalid"); + }; } public static EnumOptionData interestType(final Integer id) { @@ -289,20 +208,12 @@ public final class LoanEnumerations { } public static EnumOptionData interestType(final InterestMethod type) { - EnumOptionData optionData = null; - switch (type) { - case FLAT: - optionData = new EnumOptionData(InterestMethod.FLAT.getValue().longValue(), InterestMethod.FLAT.getCode(), "Flat"); - break; - case DECLINING_BALANCE: - optionData = new EnumOptionData(InterestMethod.DECLINING_BALANCE.getValue().longValue(), - InterestMethod.DECLINING_BALANCE.getCode(), "Declining Balance"); - break; - default: - optionData = new EnumOptionData(InterestMethod.INVALID.getValue().longValue(), InterestMethod.INVALID.getCode(), "Invalid"); - break; - } - return optionData; + return switch (type) { + case FLAT -> new EnumOptionData(InterestMethod.FLAT.getValue().longValue(), InterestMethod.FLAT.getCode(), "Flat"); + case DECLINING_BALANCE -> new EnumOptionData(InterestMethod.DECLINING_BALANCE.getValue().longValue(), + InterestMethod.DECLINING_BALANCE.getCode(), "Declining Balance"); + default -> new EnumOptionData(InterestMethod.INVALID.getValue().longValue(), InterestMethod.INVALID.getCode(), "Invalid"); + }; } public static EnumOptionData interestCalculationPeriodType(final Integer id) { @@ -310,22 +221,15 @@ public final class LoanEnumerations { } public static EnumOptionData interestCalculationPeriodType(final InterestCalculationPeriodMethod type) { - EnumOptionData optionData = null; - switch (type) { - case DAILY: - optionData = new EnumOptionData(InterestCalculationPeriodMethod.DAILY.getValue().longValue(), - InterestCalculationPeriodMethod.DAILY.getCode(), "Daily"); - break; - case SAME_AS_REPAYMENT_PERIOD: - optionData = new EnumOptionData(InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getValue().longValue(), - InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getCode(), "Same as repayment period"); - break; - default: - optionData = new EnumOptionData(InterestCalculationPeriodMethod.INVALID.getValue().longValue(), - InterestCalculationPeriodMethod.INVALID.getCode(), "Invalid"); - break; - } - return optionData; + return switch (type) { + case DAILY -> new EnumOptionData(InterestCalculationPeriodMethod.DAILY.getValue().longValue(), + InterestCalculationPeriodMethod.DAILY.getCode(), "Daily"); + case SAME_AS_REPAYMENT_PERIOD -> new EnumOptionData( + InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getValue().longValue(), + InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getCode(), "Same as repayment period"); + default -> new EnumOptionData(InterestCalculationPeriodMethod.INVALID.getValue().longValue(), + InterestCalculationPeriodMethod.INVALID.getCode(), "Invalid"); + }; } public static LoanTransactionEnumData transactionType(final Integer id) { @@ -333,106 +237,57 @@ public final class LoanEnumerations { } public static LoanTransactionEnumData transactionType(final LoanTransactionType type) { - LoanTransactionEnumData optionData = null; - switch (type) { - case INVALID: - optionData = new LoanTransactionEnumData(LoanTransactionType.INVALID.getValue().longValue(), - LoanTransactionType.INVALID.getCode(), "Invalid"); - break; - case DISBURSEMENT: - optionData = new LoanTransactionEnumData(LoanTransactionType.DISBURSEMENT.getValue().longValue(), - LoanTransactionType.DISBURSEMENT.getCode(), "Disbursement"); - break; - case REPAYMENT: - optionData = new LoanTransactionEnumData(LoanTransactionType.REPAYMENT.getValue().longValue(), - LoanTransactionType.REPAYMENT.getCode(), "Repayment"); - break; - case REPAYMENT_AT_DISBURSEMENT: - optionData = new LoanTransactionEnumData(LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue().longValue(), - LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getCode(), "Repayment (at time of disbursement)"); - break; - case CONTRA: - optionData = new LoanTransactionEnumData(LoanTransactionType.CONTRA.getValue().longValue(), - LoanTransactionType.CONTRA.getCode(), "Reversal"); - break; - case WAIVE_INTEREST: - optionData = new LoanTransactionEnumData(LoanTransactionType.WAIVE_INTEREST.getValue().longValue(), - LoanTransactionType.WAIVE_INTEREST.getCode(), "Waive interest"); - break; - case MARKED_FOR_RESCHEDULING: - optionData = new LoanTransactionEnumData(LoanTransactionType.MARKED_FOR_RESCHEDULING.getValue().longValue(), - LoanTransactionType.MARKED_FOR_RESCHEDULING.getCode(), "Close (as rescheduled)"); - break; - case WRITEOFF: - optionData = new LoanTransactionEnumData(LoanTransactionType.WRITEOFF.getValue().longValue(), - LoanTransactionType.WRITEOFF.getCode(), "Close (as written-off)"); - break; - case RECOVERY_REPAYMENT: - optionData = new LoanTransactionEnumData(LoanTransactionType.RECOVERY_REPAYMENT.getValue().longValue(), - LoanTransactionType.RECOVERY_REPAYMENT.getCode(), "Repayment (after write-off)"); - break; - case WAIVE_CHARGES: - optionData = new LoanTransactionEnumData(LoanTransactionType.WAIVE_CHARGES.getValue().longValue(), - LoanTransactionType.WAIVE_CHARGES.getCode(), "Waive loan charges"); - break; - case ACCRUAL: - optionData = new LoanTransactionEnumData(LoanTransactionType.ACCRUAL.getValue().longValue(), - LoanTransactionType.ACCRUAL.getCode(), "Accrual"); - break; - case APPROVE_TRANSFER: - optionData = new LoanTransactionEnumData(LoanTransactionType.APPROVE_TRANSFER.getValue().longValue(), - LoanTransactionType.APPROVE_TRANSFER.getCode(), "Transfer approved"); - break; - case INITIATE_TRANSFER: - optionData = new LoanTransactionEnumData(LoanTransactionType.INITIATE_TRANSFER.getValue().longValue(), - LoanTransactionType.INITIATE_TRANSFER.getCode(), "Transfer initiated"); - break; - case WITHDRAW_TRANSFER: - optionData = new LoanTransactionEnumData(LoanTransactionType.WITHDRAW_TRANSFER.getValue().longValue(), - LoanTransactionType.WITHDRAW_TRANSFER.getCode(), "Transfer Withdrawn"); - break; - case REJECT_TRANSFER: - optionData = new LoanTransactionEnumData(LoanTransactionType.REJECT_TRANSFER.getValue().longValue(), - LoanTransactionType.REJECT_TRANSFER.getCode(), "Transfer Rejected"); - break; - case REFUND: - optionData = new LoanTransactionEnumData(LoanTransactionType.REFUND.getValue().longValue(), - LoanTransactionType.REFUND.getCode(), "Transfer Refund"); - break; - case CHARGE_PAYMENT: - optionData = new LoanTransactionEnumData(LoanTransactionType.CHARGE_PAYMENT.getValue().longValue(), - LoanTransactionType.CHARGE_PAYMENT.getCode(), "Charge Payment"); - break; - case REFUND_FOR_ACTIVE_LOAN: - optionData = new LoanTransactionEnumData(LoanTransactionType.REFUND_FOR_ACTIVE_LOAN.getValue().longValue(), - LoanTransactionType.REFUND_FOR_ACTIVE_LOAN.getCode(), "Refund"); - break; - case INCOME_POSTING: - optionData = new LoanTransactionEnumData(LoanTransactionType.INCOME_POSTING.getValue().longValue(), - LoanTransactionType.INCOME_POSTING.getCode(), "Income Posting"); - break; - case CREDIT_BALANCE_REFUND: - optionData = new LoanTransactionEnumData(LoanTransactionType.CREDIT_BALANCE_REFUND.getValue().longValue(), - LoanTransactionType.CREDIT_BALANCE_REFUND.getCode(), "Credit Balance Refund"); - break; - case MERCHANT_ISSUED_REFUND: - optionData = new LoanTransactionEnumData(LoanTransactionType.MERCHANT_ISSUED_REFUND.getValue().longValue(), - LoanTransactionType.MERCHANT_ISSUED_REFUND.getCode(), "Merchant Issued Refund"); - break; - case PAYOUT_REFUND: - optionData = new LoanTransactionEnumData(LoanTransactionType.PAYOUT_REFUND.getValue().longValue(), - LoanTransactionType.PAYOUT_REFUND.getCode(), "Payout Refund"); - break; - case GOODWILL_CREDIT: - optionData = new LoanTransactionEnumData(LoanTransactionType.GOODWILL_CREDIT.getValue().longValue(), - LoanTransactionType.GOODWILL_CREDIT.getCode(), "Goodwill Credit"); - break; - case CHARGE_REFUND: - optionData = new LoanTransactionEnumData(LoanTransactionType.CHARGE_REFUND.getValue().longValue(), - LoanTransactionType.CHARGE_REFUND.getCode(), "Charge Refund"); - break; - } - return optionData; + return switch (type) { + case INVALID -> new LoanTransactionEnumData(LoanTransactionType.INVALID.getValue().longValue(), + LoanTransactionType.INVALID.getCode(), "Invalid"); + case DISBURSEMENT -> new LoanTransactionEnumData(LoanTransactionType.DISBURSEMENT.getValue().longValue(), + LoanTransactionType.DISBURSEMENT.getCode(), "Disbursement"); + case REPAYMENT -> new LoanTransactionEnumData(LoanTransactionType.REPAYMENT.getValue().longValue(), + LoanTransactionType.REPAYMENT.getCode(), "Repayment"); + case REPAYMENT_AT_DISBURSEMENT -> new LoanTransactionEnumData( + LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue().longValue(), + LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getCode(), "Repayment (at time of disbursement)"); + case CONTRA -> new LoanTransactionEnumData(LoanTransactionType.CONTRA.getValue().longValue(), + LoanTransactionType.CONTRA.getCode(), "Reversal"); + case WAIVE_INTEREST -> new LoanTransactionEnumData(LoanTransactionType.WAIVE_INTEREST.getValue().longValue(), + LoanTransactionType.WAIVE_INTEREST.getCode(), "Waive interest"); + case MARKED_FOR_RESCHEDULING -> new LoanTransactionEnumData(LoanTransactionType.MARKED_FOR_RESCHEDULING.getValue().longValue(), + LoanTransactionType.MARKED_FOR_RESCHEDULING.getCode(), "Close (as rescheduled)"); + case WRITEOFF -> new LoanTransactionEnumData(LoanTransactionType.WRITEOFF.getValue().longValue(), + LoanTransactionType.WRITEOFF.getCode(), "Close (as written-off)"); + case RECOVERY_REPAYMENT -> new LoanTransactionEnumData(LoanTransactionType.RECOVERY_REPAYMENT.getValue().longValue(), + LoanTransactionType.RECOVERY_REPAYMENT.getCode(), "Repayment (after write-off)"); + case WAIVE_CHARGES -> new LoanTransactionEnumData(LoanTransactionType.WAIVE_CHARGES.getValue().longValue(), + LoanTransactionType.WAIVE_CHARGES.getCode(), "Waive loan charges"); + case ACCRUAL -> new LoanTransactionEnumData(LoanTransactionType.ACCRUAL.getValue().longValue(), + LoanTransactionType.ACCRUAL.getCode(), "Accrual"); + case APPROVE_TRANSFER -> new LoanTransactionEnumData(LoanTransactionType.APPROVE_TRANSFER.getValue().longValue(), + LoanTransactionType.APPROVE_TRANSFER.getCode(), "Transfer approved"); + case INITIATE_TRANSFER -> new LoanTransactionEnumData(LoanTransactionType.INITIATE_TRANSFER.getValue().longValue(), + LoanTransactionType.INITIATE_TRANSFER.getCode(), "Transfer initiated"); + case WITHDRAW_TRANSFER -> new LoanTransactionEnumData(LoanTransactionType.WITHDRAW_TRANSFER.getValue().longValue(), + LoanTransactionType.WITHDRAW_TRANSFER.getCode(), "Transfer Withdrawn"); + case REJECT_TRANSFER -> new LoanTransactionEnumData(LoanTransactionType.REJECT_TRANSFER.getValue().longValue(), + LoanTransactionType.REJECT_TRANSFER.getCode(), "Transfer Rejected"); + case REFUND -> new LoanTransactionEnumData(LoanTransactionType.REFUND.getValue().longValue(), + LoanTransactionType.REFUND.getCode(), "Transfer Refund"); + case CHARGE_PAYMENT -> new LoanTransactionEnumData(LoanTransactionType.CHARGE_PAYMENT.getValue().longValue(), + LoanTransactionType.CHARGE_PAYMENT.getCode(), "Charge Payment"); + case REFUND_FOR_ACTIVE_LOAN -> new LoanTransactionEnumData(LoanTransactionType.REFUND_FOR_ACTIVE_LOAN.getValue().longValue(), + LoanTransactionType.REFUND_FOR_ACTIVE_LOAN.getCode(), "Refund"); + case INCOME_POSTING -> new LoanTransactionEnumData(LoanTransactionType.INCOME_POSTING.getValue().longValue(), + LoanTransactionType.INCOME_POSTING.getCode(), "Income Posting"); + case CREDIT_BALANCE_REFUND -> new LoanTransactionEnumData(LoanTransactionType.CREDIT_BALANCE_REFUND.getValue().longValue(), + LoanTransactionType.CREDIT_BALANCE_REFUND.getCode(), "Credit Balance Refund"); + case MERCHANT_ISSUED_REFUND -> new LoanTransactionEnumData(LoanTransactionType.MERCHANT_ISSUED_REFUND.getValue().longValue(), + LoanTransactionType.MERCHANT_ISSUED_REFUND.getCode(), "Merchant Issued Refund"); + case PAYOUT_REFUND -> new LoanTransactionEnumData(LoanTransactionType.PAYOUT_REFUND.getValue().longValue(), + LoanTransactionType.PAYOUT_REFUND.getCode(), "Payout Refund"); + case GOODWILL_CREDIT -> new LoanTransactionEnumData(LoanTransactionType.GOODWILL_CREDIT.getValue().longValue(), + LoanTransactionType.GOODWILL_CREDIT.getCode(), "Goodwill Credit"); + case CHARGE_REFUND -> new LoanTransactionEnumData(LoanTransactionType.CHARGE_REFUND.getValue().longValue(), + LoanTransactionType.CHARGE_REFUND.getCode(), "Charge Refund"); + }; } public static EnumOptionData status(final LoanStatusEnumData status) { @@ -449,55 +304,28 @@ public final class LoanEnumerations { } public static LoanStatusEnumData status(final LoanStatus status) { - LoanStatusEnumData optionData = new LoanStatusEnumData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(), - "Invalid"); - switch (status) { - case INVALID: - optionData = new LoanStatusEnumData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(), "Invalid"); - break; - case SUBMITTED_AND_PENDING_APPROVAL: - optionData = new LoanStatusEnumData(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue().longValue(), - LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getCode(), "Submitted and pending approval"); - break; - case APPROVED: - optionData = new LoanStatusEnumData(LoanStatus.APPROVED.getValue().longValue(), LoanStatus.APPROVED.getCode(), "Approved"); - break; - case ACTIVE: - optionData = new LoanStatusEnumData(LoanStatus.ACTIVE.getValue().longValue(), LoanStatus.ACTIVE.getCode(), "Active"); - break; - case REJECTED: - optionData = new LoanStatusEnumData(LoanStatus.REJECTED.getValue().longValue(), LoanStatus.REJECTED.getCode(), "Rejected"); - break; - case WITHDRAWN_BY_CLIENT: - optionData = new LoanStatusEnumData(LoanStatus.WITHDRAWN_BY_CLIENT.getValue().longValue(), - LoanStatus.WITHDRAWN_BY_CLIENT.getCode(), "Withdrawn by applicant"); - break; - case CLOSED_OBLIGATIONS_MET: - optionData = new LoanStatusEnumData(LoanStatus.CLOSED_OBLIGATIONS_MET.getValue().longValue(), - LoanStatus.CLOSED_OBLIGATIONS_MET.getCode(), "Closed (obligations met)"); - break; - case CLOSED_WRITTEN_OFF: - optionData = new LoanStatusEnumData(LoanStatus.CLOSED_WRITTEN_OFF.getValue().longValue(), - LoanStatus.CLOSED_WRITTEN_OFF.getCode(), "Closed (written off)"); - break; - case CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT: - optionData = new LoanStatusEnumData(LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getValue().longValue(), - LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getCode(), "Closed (rescheduled)"); - break; - case OVERPAID: - optionData = new LoanStatusEnumData(LoanStatus.OVERPAID.getValue().longValue(), LoanStatus.OVERPAID.getCode(), "Overpaid"); - break; - case TRANSFER_IN_PROGRESS: - optionData = new LoanStatusEnumData(LoanStatus.TRANSFER_IN_PROGRESS.getValue().longValue(), - LoanStatus.TRANSFER_IN_PROGRESS.getCode(), "Transfer in progress"); - break; - case TRANSFER_ON_HOLD: - optionData = new LoanStatusEnumData(LoanStatus.TRANSFER_ON_HOLD.getValue().longValue(), - LoanStatus.TRANSFER_ON_HOLD.getCode(), "Transfer on hold"); - break; - } - - return optionData; + return switch (status) { + case INVALID -> new LoanStatusEnumData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(), "Invalid"); + case SUBMITTED_AND_PENDING_APPROVAL -> new LoanStatusEnumData(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue().longValue(), + LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getCode(), "Submitted and pending approval"); + case APPROVED -> new LoanStatusEnumData(LoanStatus.APPROVED.getValue().longValue(), LoanStatus.APPROVED.getCode(), "Approved"); + case ACTIVE -> new LoanStatusEnumData(LoanStatus.ACTIVE.getValue().longValue(), LoanStatus.ACTIVE.getCode(), "Active"); + case REJECTED -> new LoanStatusEnumData(LoanStatus.REJECTED.getValue().longValue(), LoanStatus.REJECTED.getCode(), "Rejected"); + case WITHDRAWN_BY_CLIENT -> new LoanStatusEnumData(LoanStatus.WITHDRAWN_BY_CLIENT.getValue().longValue(), + LoanStatus.WITHDRAWN_BY_CLIENT.getCode(), "Withdrawn by applicant"); + case CLOSED_OBLIGATIONS_MET -> new LoanStatusEnumData(LoanStatus.CLOSED_OBLIGATIONS_MET.getValue().longValue(), + LoanStatus.CLOSED_OBLIGATIONS_MET.getCode(), "Closed (obligations met)"); + case CLOSED_WRITTEN_OFF -> new LoanStatusEnumData(LoanStatus.CLOSED_WRITTEN_OFF.getValue().longValue(), + LoanStatus.CLOSED_WRITTEN_OFF.getCode(), "Closed (written off)"); + case CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT -> new LoanStatusEnumData( + LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getValue().longValue(), + LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getCode(), "Closed (rescheduled)"); + case OVERPAID -> new LoanStatusEnumData(LoanStatus.OVERPAID.getValue().longValue(), LoanStatus.OVERPAID.getCode(), "Overpaid"); + case TRANSFER_IN_PROGRESS -> new LoanStatusEnumData(LoanStatus.TRANSFER_IN_PROGRESS.getValue().longValue(), + LoanStatus.TRANSFER_IN_PROGRESS.getCode(), "Transfer in progress"); + case TRANSFER_ON_HOLD -> new LoanStatusEnumData(LoanStatus.TRANSFER_ON_HOLD.getValue().longValue(), + LoanStatus.TRANSFER_ON_HOLD.getCode(), "Transfer on hold"); + }; } public static EnumOptionData loanCycleValueConditionType(final int id) { @@ -505,22 +333,14 @@ public final class LoanEnumerations { } public static EnumOptionData loanCycleValueConditionType(final LoanProductValueConditionType type) { - EnumOptionData optionData = null; - switch (type) { - case EQUAL: - optionData = new EnumOptionData(LoanProductValueConditionType.EQUAL.getValue().longValue(), - LoanProductValueConditionType.EQUAL.getCode(), "equals"); - break; - case GREATERTHAN: - optionData = new EnumOptionData(LoanProductValueConditionType.GREATERTHAN.getValue().longValue(), - LoanProductValueConditionType.GREATERTHAN.getCode(), "greater than"); - break; - default: - optionData = new EnumOptionData(LoanProductValueConditionType.INVALID.getValue().longValue(), - LoanProductValueConditionType.INVALID.getCode(), "Invalid"); - break; - } - return optionData; + return switch (type) { + case EQUAL -> new EnumOptionData(LoanProductValueConditionType.EQUAL.getValue().longValue(), + LoanProductValueConditionType.EQUAL.getCode(), "equals"); + case GREATERTHAN -> new EnumOptionData(LoanProductValueConditionType.GREATERTHAN.getValue().longValue(), + LoanProductValueConditionType.GREATERTHAN.getCode(), "greater than"); + default -> new EnumOptionData(LoanProductValueConditionType.INVALID.getValue().longValue(), + LoanProductValueConditionType.INVALID.getCode(), "Invalid"); + }; } public static EnumOptionData loanCycleParamType(final int id) { @@ -528,81 +348,48 @@ public final class LoanEnumerations { } public static EnumOptionData loanCycleParamType(final LoanProductParamType type) { - EnumOptionData optionData = null; - switch (type) { - case PRINCIPAL: - optionData = new EnumOptionData(LoanProductParamType.PRINCIPAL.getValue().longValue(), - LoanProductParamType.PRINCIPAL.getCode(), "principal"); - break; - case INTERESTRATE: - optionData = new EnumOptionData(LoanProductParamType.INTERESTRATE.getValue().longValue(), - LoanProductParamType.INTERESTRATE.getCode(), "Interest rate"); - break; - case REPAYMENT: - optionData = new EnumOptionData(LoanProductParamType.REPAYMENT.getValue().longValue(), - LoanProductParamType.REPAYMENT.getCode(), "repayment"); - break; - default: - optionData = new EnumOptionData(LoanProductParamType.INVALID.getValue().longValue(), LoanProductParamType.INVALID.getCode(), - "Invalid"); - break; - } - return optionData; + return switch (type) { + case PRINCIPAL -> new EnumOptionData(LoanProductParamType.PRINCIPAL.getValue().longValue(), + LoanProductParamType.PRINCIPAL.getCode(), "principal"); + case INTERESTRATE -> new EnumOptionData(LoanProductParamType.INTERESTRATE.getValue().longValue(), + LoanProductParamType.INTERESTRATE.getCode(), "Interest rate"); + case REPAYMENT -> new EnumOptionData(LoanProductParamType.REPAYMENT.getValue().longValue(), + LoanProductParamType.REPAYMENT.getCode(), "repayment"); + default -> new EnumOptionData(LoanProductParamType.INVALID.getValue().longValue(), LoanProductParamType.INVALID.getCode(), + "Invalid"); + }; } - public static EnumOptionData loanvariationType(final int id) { - return loanvariationType(LoanTermVariationType.fromInt(id)); + public static EnumOptionData loanVariationType(final int id) { + return loanVariationType(LoanTermVariationType.fromInt(id)); } - public static EnumOptionData loanvariationType(final LoanTermVariationType type) { - EnumOptionData optionData = null; - switch (type) { - case EMI_AMOUNT: - optionData = new EnumOptionData(LoanTermVariationType.EMI_AMOUNT.getValue().longValue(), - LoanTermVariationType.EMI_AMOUNT.getCode(), "emiAmount"); - break; - case INTEREST_RATE: - optionData = new EnumOptionData(LoanTermVariationType.INTEREST_RATE.getValue().longValue(), - LoanTermVariationType.INTEREST_RATE.getCode(), "interestRate"); - break; - case DELETE_INSTALLMENT: - optionData = new EnumOptionData(LoanTermVariationType.DELETE_INSTALLMENT.getValue().longValue(), - LoanTermVariationType.DELETE_INSTALLMENT.getCode(), "deleteInstallment"); - break; - case DUE_DATE: - optionData = new EnumOptionData(LoanTermVariationType.DUE_DATE.getValue().longValue(), - LoanTermVariationType.DUE_DATE.getCode(), "dueDate"); - break; - case INSERT_INSTALLMENT: - optionData = new EnumOptionData(LoanTermVariationType.INSERT_INSTALLMENT.getValue().longValue(), - LoanTermVariationType.DUE_DATE.getCode(), "insertInstallment"); - break; - case PRINCIPAL_AMOUNT: - optionData = new EnumOptionData(LoanTermVariationType.PRINCIPAL_AMOUNT.getValue().longValue(), - LoanTermVariationType.PRINCIPAL_AMOUNT.getCode(), "principalAmount"); - break; - case GRACE_ON_INTEREST: - optionData = new EnumOptionData(LoanTermVariationType.GRACE_ON_INTEREST.getValue().longValue(), - LoanTermVariationType.GRACE_ON_INTEREST.getCode(), "graceOnInterest"); - break; - case GRACE_ON_PRINCIPAL: - optionData = new EnumOptionData(LoanTermVariationType.GRACE_ON_PRINCIPAL.getValue().longValue(), - LoanTermVariationType.GRACE_ON_PRINCIPAL.getCode(), "graceOnPrincipal"); - break; - case EXTEND_REPAYMENT_PERIOD: - optionData = new EnumOptionData(LoanTermVariationType.EXTEND_REPAYMENT_PERIOD.getValue().longValue(), - LoanTermVariationType.EXTEND_REPAYMENT_PERIOD.getCode(), "extendRepaymentPeriod"); - break; - case INTEREST_RATE_FROM_INSTALLMENT: - optionData = new EnumOptionData(LoanTermVariationType.INTEREST_RATE_FROM_INSTALLMENT.getValue().longValue(), - LoanTermVariationType.INTEREST_RATE_FROM_INSTALLMENT.getCode(), "interestRateForInstallment"); - break; - default: - optionData = new EnumOptionData(LoanTermVariationType.INVALID.getValue().longValue(), - LoanTermVariationType.INVALID.getCode(), "Invalid"); - break; - } - return optionData; + public static EnumOptionData loanVariationType(final LoanTermVariationType type) { + return switch (type) { + case EMI_AMOUNT -> new EnumOptionData(LoanTermVariationType.EMI_AMOUNT.getValue().longValue(), + LoanTermVariationType.EMI_AMOUNT.getCode(), "emiAmount"); + case INTEREST_RATE -> new EnumOptionData(LoanTermVariationType.INTEREST_RATE.getValue().longValue(), + LoanTermVariationType.INTEREST_RATE.getCode(), "interestRate"); + case DELETE_INSTALLMENT -> new EnumOptionData(LoanTermVariationType.DELETE_INSTALLMENT.getValue().longValue(), + LoanTermVariationType.DELETE_INSTALLMENT.getCode(), "deleteInstallment"); + case DUE_DATE -> new EnumOptionData(LoanTermVariationType.DUE_DATE.getValue().longValue(), + LoanTermVariationType.DUE_DATE.getCode(), "dueDate"); + case INSERT_INSTALLMENT -> new EnumOptionData(LoanTermVariationType.INSERT_INSTALLMENT.getValue().longValue(), + LoanTermVariationType.DUE_DATE.getCode(), "insertInstallment"); + case PRINCIPAL_AMOUNT -> new EnumOptionData(LoanTermVariationType.PRINCIPAL_AMOUNT.getValue().longValue(), + LoanTermVariationType.PRINCIPAL_AMOUNT.getCode(), "principalAmount"); + case GRACE_ON_INTEREST -> new EnumOptionData(LoanTermVariationType.GRACE_ON_INTEREST.getValue().longValue(), + LoanTermVariationType.GRACE_ON_INTEREST.getCode(), "graceOnInterest"); + case GRACE_ON_PRINCIPAL -> new EnumOptionData(LoanTermVariationType.GRACE_ON_PRINCIPAL.getValue().longValue(), + LoanTermVariationType.GRACE_ON_PRINCIPAL.getCode(), "graceOnPrincipal"); + case EXTEND_REPAYMENT_PERIOD -> new EnumOptionData(LoanTermVariationType.EXTEND_REPAYMENT_PERIOD.getValue().longValue(), + LoanTermVariationType.EXTEND_REPAYMENT_PERIOD.getCode(), "extendRepaymentPeriod"); + case INTEREST_RATE_FROM_INSTALLMENT -> new EnumOptionData( + LoanTermVariationType.INTEREST_RATE_FROM_INSTALLMENT.getValue().longValue(), + LoanTermVariationType.INTEREST_RATE_FROM_INSTALLMENT.getCode(), "interestRateForInstallment"); + default -> new EnumOptionData(LoanTermVariationType.INVALID.getValue().longValue(), LoanTermVariationType.INVALID.getCode(), + "Invalid"); + }; } public static EnumOptionData interestRecalculationCompoundingType(final int id) { @@ -610,26 +397,16 @@ public final class LoanEnumerations { } public static EnumOptionData interestRecalculationCompoundingType(final InterestRecalculationCompoundingMethod type) { - EnumOptionData optionData = null; - switch (type) { - case FEE: - optionData = new EnumOptionData(InterestRecalculationCompoundingMethod.FEE.getValue().longValue(), - InterestRecalculationCompoundingMethod.FEE.getCode(), "Fee"); - break; - case INTEREST: - optionData = new EnumOptionData(InterestRecalculationCompoundingMethod.INTEREST.getValue().longValue(), - InterestRecalculationCompoundingMethod.INTEREST.getCode(), "Interest"); - break; - case INTEREST_AND_FEE: - optionData = new EnumOptionData(InterestRecalculationCompoundingMethod.INTEREST_AND_FEE.getValue().longValue(), - InterestRecalculationCompoundingMethod.INTEREST_AND_FEE.getCode(), "Fee and Interest"); - break; - default: - optionData = new EnumOptionData(InterestRecalculationCompoundingMethod.NONE.getValue().longValue(), - InterestRecalculationCompoundingMethod.NONE.getCode(), "None"); - break; - } - return optionData; + return switch (type) { + case FEE -> new EnumOptionData(InterestRecalculationCompoundingMethod.FEE.getValue().longValue(), + InterestRecalculationCompoundingMethod.FEE.getCode(), "Fee"); + case INTEREST -> new EnumOptionData(InterestRecalculationCompoundingMethod.INTEREST.getValue().longValue(), + InterestRecalculationCompoundingMethod.INTEREST.getCode(), "Interest"); + case INTEREST_AND_FEE -> new EnumOptionData(InterestRecalculationCompoundingMethod.INTEREST_AND_FEE.getValue().longValue(), + InterestRecalculationCompoundingMethod.INTEREST_AND_FEE.getCode(), "Fee and Interest"); + default -> new EnumOptionData(InterestRecalculationCompoundingMethod.NONE.getValue().longValue(), + InterestRecalculationCompoundingMethod.NONE.getCode(), "None"); + }; } public static EnumOptionData interestRecalculationCompoundingNthDayType(final Integer id) { @@ -642,31 +419,15 @@ public final class LoanEnumerations { public static EnumOptionData interestRecalculationCompoundingNthDayType(final NthDayType type) { final String codePrefix = "interestRecalculationCompounding."; long nthDayValue = type.getValue().longValue(); - EnumOptionData optionData = null; - switch (type) { - case ONE: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "first"); - break; - case TWO: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "second"); - break; - case THREE: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "third"); - break; - case FOUR: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fourth"); - break; - case FIVE: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fifth"); - break; - case LAST: - optionData = new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "last"); - break; - default: - optionData = new EnumOptionData(Integer.valueOf(0).longValue(), codePrefix + type.getCode(), "invalid"); - break; - } - return optionData; + return switch (type) { + case ONE -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "first"); + case TWO -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "second"); + case THREE -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "third"); + case FOUR -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fourth"); + case FIVE -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "fifth"); + case LAST -> new EnumOptionData(nthDayValue, codePrefix + type.getCode(), "last"); + default -> new EnumOptionData(Integer.valueOf(0).longValue(), codePrefix + type.getCode(), "invalid"); + }; } public static EnumOptionData interestRecalculationCompoundingDayOfWeekType(final Integer id) { @@ -678,8 +439,7 @@ public final class LoanEnumerations { public static EnumOptionData interestRecalculationCompoundingDayOfWeekType(final DayOfWeekType type) { final String codePrefix = "interestRecalculationCompounding."; - EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), codePrefix + type.getCode(), type.toString()); - return optionData; + return new EnumOptionData(type.getValue().longValue(), codePrefix + type.getCode(), type.toString()); } public static EnumOptionData rescheduleStrategyType(final int id) { @@ -687,26 +447,18 @@ public final class LoanEnumerations { } public static EnumOptionData rescheduleStrategyType(final LoanRescheduleStrategyMethod type) { - EnumOptionData optionData = null; - switch (type) { - case REDUCE_EMI_AMOUNT: - optionData = new EnumOptionData(LoanRescheduleStrategyMethod.REDUCE_EMI_AMOUNT.getValue().longValue(), - LoanRescheduleStrategyMethod.REDUCE_EMI_AMOUNT.getCode(), "Reduce EMI amount"); - break; - case REDUCE_NUMBER_OF_INSTALLMENTS: - optionData = new EnumOptionData(LoanRescheduleStrategyMethod.REDUCE_NUMBER_OF_INSTALLMENTS.getValue().longValue(), - LoanRescheduleStrategyMethod.REDUCE_NUMBER_OF_INSTALLMENTS.getCode(), "Reduce number of installments"); - break; - case RESCHEDULE_NEXT_REPAYMENTS: - optionData = new EnumOptionData(LoanRescheduleStrategyMethod.RESCHEDULE_NEXT_REPAYMENTS.getValue().longValue(), - LoanRescheduleStrategyMethod.RESCHEDULE_NEXT_REPAYMENTS.getCode(), "Reschedule next repayments"); - break; - default: - optionData = new EnumOptionData(LoanRescheduleStrategyMethod.INVALID.getValue().longValue(), - LoanRescheduleStrategyMethod.INVALID.getCode(), "Invalid"); - break; - } - return optionData; + return switch (type) { + case REDUCE_EMI_AMOUNT -> new EnumOptionData(LoanRescheduleStrategyMethod.REDUCE_EMI_AMOUNT.getValue().longValue(), + LoanRescheduleStrategyMethod.REDUCE_EMI_AMOUNT.getCode(), "Reduce EMI amount"); + case REDUCE_NUMBER_OF_INSTALLMENTS -> new EnumOptionData( + LoanRescheduleStrategyMethod.REDUCE_NUMBER_OF_INSTALLMENTS.getValue().longValue(), + LoanRescheduleStrategyMethod.REDUCE_NUMBER_OF_INSTALLMENTS.getCode(), "Reduce number of installments"); + case RESCHEDULE_NEXT_REPAYMENTS -> new EnumOptionData( + LoanRescheduleStrategyMethod.RESCHEDULE_NEXT_REPAYMENTS.getValue().longValue(), + LoanRescheduleStrategyMethod.RESCHEDULE_NEXT_REPAYMENTS.getCode(), "Reschedule next repayments"); + default -> new EnumOptionData(LoanRescheduleStrategyMethod.INVALID.getValue().longValue(), + LoanRescheduleStrategyMethod.INVALID.getCode(), "Invalid"); + }; } public static EnumOptionData interestRecalculationFrequencyType(final int id) { @@ -714,31 +466,18 @@ public final class LoanEnumerations { } public static EnumOptionData interestRecalculationFrequencyType(final RecalculationFrequencyType type) { - EnumOptionData optionData = null; - switch (type) { - case DAILY: - optionData = new EnumOptionData(RecalculationFrequencyType.DAILY.getValue().longValue(), - RecalculationFrequencyType.DAILY.getCode(), "Daily"); - break; - case MONTHLY: - optionData = new EnumOptionData(RecalculationFrequencyType.MONTHLY.getValue().longValue(), - RecalculationFrequencyType.MONTHLY.getCode(), "Monthly"); - break; - case SAME_AS_REPAYMENT_PERIOD: - optionData = new EnumOptionData(RecalculationFrequencyType.SAME_AS_REPAYMENT_PERIOD.getValue().longValue(), - RecalculationFrequencyType.SAME_AS_REPAYMENT_PERIOD.getCode(), "Same as repayment period"); - break; - case WEEKLY: - optionData = new EnumOptionData(RecalculationFrequencyType.WEEKLY.getValue().longValue(), - RecalculationFrequencyType.WEEKLY.getCode(), "Weekly"); - break; - default: - optionData = new EnumOptionData(RecalculationFrequencyType.INVALID.getValue().longValue(), - RecalculationFrequencyType.INVALID.getCode(), "Invalid"); - break; - - } - return optionData; + return switch (type) { + case DAILY -> new EnumOptionData(RecalculationFrequencyType.DAILY.getValue().longValue(), + RecalculationFrequencyType.DAILY.getCode(), "Daily"); + case MONTHLY -> new EnumOptionData(RecalculationFrequencyType.MONTHLY.getValue().longValue(), + RecalculationFrequencyType.MONTHLY.getCode(), "Monthly"); + case SAME_AS_REPAYMENT_PERIOD -> new EnumOptionData(RecalculationFrequencyType.SAME_AS_REPAYMENT_PERIOD.getValue().longValue(), + RecalculationFrequencyType.SAME_AS_REPAYMENT_PERIOD.getCode(), "Same as repayment period"); + case WEEKLY -> new EnumOptionData(RecalculationFrequencyType.WEEKLY.getValue().longValue(), + RecalculationFrequencyType.WEEKLY.getCode(), "Weekly"); + default -> new EnumOptionData(RecalculationFrequencyType.INVALID.getValue().longValue(), + RecalculationFrequencyType.INVALID.getCode(), "Invalid"); + }; } public static EnumOptionData preCloseInterestCalculationStrategy(final int id) { @@ -750,11 +489,11 @@ public final class LoanEnumerations { switch (type) { case TILL_PRE_CLOSURE_DATE: optionData = new EnumOptionData(LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue().longValue(), - LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getCode(), "Till preclose Date"); + LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getCode(), "Till Pre-Close Date"); break; case TILL_REST_FREQUENCY_DATE: optionData = new EnumOptionData(LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getValue().longValue(), - LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getCode(), "Till rest Frequency Date"); + LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getCode(), "Till Rest Frequency Date"); break; case NONE: break; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java index 785e849bb..3bdd52100 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java @@ -47,6 +47,7 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanProductParamType; import org.apache.fineract.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.apache.fineract.portfolio.rate.data.RateData; import org.apache.fineract.portfolio.rate.service.RateReadService; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; @@ -91,7 +92,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo final LoanProductMapper rm = new LoanProductMapper(charges, borrowerCycleVariationDatas, rates, delinquencyBucketOptions); final String sql = "select " + rm.loanProductSchema() + " where lp.id = ?"; - return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanProductId }); // NOSONAR + return this.jdbcTemplate.queryForObject(sql, rm, loanProductId); // NOSONAR } catch (final EmptyResultDataAccessException e) { throw new LoanProductNotFoundException(loanProductId, e); @@ -102,7 +103,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo public Collection retrieveLoanProductBorrowerCycleVariations(final Long loanProductId) { final LoanProductBorrowerCycleMapper rm = new LoanProductBorrowerCycleMapper(); final String sql = "select " + rm.schema() + " where bc.loan_product_id=? order by bc.borrower_cycle_number,bc.value_condition"; - return this.jdbcTemplate.query(sql, rm, new Object[] { loanProductId }); // NOSONAR + return this.jdbcTemplate.query(sql, rm, loanProductId); // NOSONAR } @Override @@ -261,7 +262,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo } @Override - public LoanProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { + public LoanProductData mapRow(@NotNull final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { final Long id = JdbcSupport.getLong(rs, "id"); final String name = rs.getString("name"); @@ -564,9 +565,8 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo final BigDecimal maxValue = rs.getBigDecimal("maxVal"); final BigDecimal minValue = rs.getBigDecimal("minVal"); - final LoanProductBorrowerCycleVariationData borrowerCycleVariationData = new LoanProductBorrowerCycleVariationData(id, - cycleNumber, paramTypeData, conditionTypeData, defaultValue, minValue, maxValue); - return borrowerCycleVariationData; + return new LoanProductBorrowerCycleVariationData(id, cycleNumber, paramTypeData, conditionTypeData, defaultValue, minValue, + maxValue); } } @@ -587,7 +587,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo sql += " and id in (" + inClause + ") "; } - return this.jdbcTemplate.query(sql, rm, new Object[] { currencyCode }); // NOSONAR + return this.jdbcTemplate.query(sql, rm, currencyCode); // NOSONAR } @Override @@ -636,7 +636,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo sql += " and lp.id in ( " + inClause2 + " ) "; } - return this.jdbcTemplate.query(sql, rm, new Object[] { productId, productId }); // NOSONAR + return this.jdbcTemplate.query(sql, rm, productId, productId); // NOSONAR } @Override @@ -659,7 +659,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo sql += "lp.id not in (" + "Select pm.restricted_product_id from m_product_mix pm where pm.product_id=? " + "UNION " + "Select pm.product_id from m_product_mix pm where pm.restricted_product_id=?)"; - return this.jdbcTemplate.query(sql, rm, new Object[] { productId, productId }); // NOSONAR + return this.jdbcTemplate.query(sql, rm, productId, productId); // NOSONAR } @Override @@ -669,7 +669,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo final LoanProductFloatingRateMapper rm = new LoanProductFloatingRateMapper(); final String sql = "select " + rm.schema() + " where lp.id = ?"; - return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanProductId }); // NOSONAR + return this.jdbcTemplate.queryForObject(sql, rm, loanProductId); // NOSONAR } catch (final EmptyResultDataAccessException e) { throw new LoanProductNotFoundException(loanProductId, e); @@ -693,7 +693,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo } @Override - public LoanProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { + public LoanProductData mapRow(@NotNull final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { final Long id = JdbcSupport.getLong(rs, "id"); final String name = rs.getString("name"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java index 7af4e1174..78cb21f0f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java @@ -274,7 +274,7 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro } catch (final DataIntegrityViolationException | JpaSystemException dve) { handleDataIntegrityIssues(command, dve.getMostSpecificCause(), dve); - return new CommandProcessingResult(Long.valueOf(-1)); + return new CommandProcessingResult((long) -1); } catch (final PersistenceException dve) { Throwable throwable = ExceptionUtils.getRootCause(dve.getCause()); handleDataIntegrityIssues(command, throwable, dve); @@ -390,6 +390,6 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro } private void logAsErrorUnexpectedDataIntegrityException(final Exception dve) { - LOG.error("Error occured.", dve); + LOG.error("Error occurred.", dve); } } diff --git a/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanproduct/LoanProductValidationStepDefinitions.java b/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanproduct/LoanProductValidationStepDefinitions.java index e7d5efdad..77ef912cc 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanproduct/LoanProductValidationStepDefinitions.java +++ b/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanproduct/LoanProductValidationStepDefinitions.java @@ -72,7 +72,7 @@ public class LoanProductValidationStepDefinitions implements En { private LoanProduct newLoanProduct(boolean allowMultipleDisbursals) { LoanProduct lp = new LoanProduct(); - lp.setLoanProducTrancheDetails(new LoanProductTrancheDetails(allowMultipleDisbursals, null, null)); + lp.setLoanProductTrancheDetails(new LoanProductTrancheDetails(allowMultipleDisbursals, null, null)); return lp; } }