FINERACT-2421: Refractor redundant and some deprecated code as per new Java 21 style (Phase 5)
This commit is contained in:
+1
-2
@@ -72,8 +72,7 @@ public final class FinancialActivityAccountDataValidator {
|
||||
}
|
||||
|
||||
private DataValidatorBuilder getDataValidator(final List<ApiParameterError> dataValidationErrors) {
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("financialactivityaccount");
|
||||
return baseDataValidator;
|
||||
return new DataValidatorBuilder(dataValidationErrors).resource("financialactivityaccount");
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
|
||||
+36
-89
@@ -33,6 +33,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
|
||||
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
@@ -66,34 +68,41 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
public static final String LOCALE_PARAM_NAME = "locale";
|
||||
public static final String FEE_FREQUENCY_PARAM_NAME = "feeFrequency";
|
||||
|
||||
@Getter
|
||||
@Column(name = "name", length = 100)
|
||||
private String name;
|
||||
|
||||
@Getter
|
||||
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal amount;
|
||||
|
||||
@Getter
|
||||
@Column(name = "currency_code", length = 3)
|
||||
private String currencyCode;
|
||||
|
||||
@Column(name = "charge_applies_to_enum", nullable = false)
|
||||
private Integer chargeAppliesTo;
|
||||
|
||||
@Getter
|
||||
@Column(name = "charge_time_enum", nullable = false)
|
||||
private Integer chargeTimeType;
|
||||
|
||||
@Getter
|
||||
@Column(name = "charge_calculation_enum")
|
||||
private Integer chargeCalculation;
|
||||
|
||||
@Column(name = "charge_payment_mode_enum", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "charge_payment_mode_enum")
|
||||
private Integer chargePaymentMode;
|
||||
|
||||
@Column(name = "fee_on_day", nullable = true)
|
||||
@Column(name = "fee_on_day")
|
||||
private Integer feeOnDay;
|
||||
|
||||
@Column(name = "fee_interval", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "fee_interval")
|
||||
private Integer feeInterval;
|
||||
|
||||
@Column(name = "fee_on_month", nullable = true)
|
||||
@Column(name = "fee_on_month")
|
||||
private Integer feeOnMonth;
|
||||
|
||||
@Column(name = "is_penalty", nullable = false)
|
||||
@@ -105,10 +114,12 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
@Column(name = "is_deleted", nullable = false)
|
||||
private boolean deleted = false;
|
||||
|
||||
@Column(name = "min_cap", scale = 6, precision = 19, nullable = true)
|
||||
@Getter
|
||||
@Column(name = "min_cap", scale = 6, precision = 19)
|
||||
private BigDecimal minCap;
|
||||
|
||||
@Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
|
||||
@Getter
|
||||
@Column(name = "max_cap", scale = 6, precision = 19)
|
||||
private BigDecimal maxCap;
|
||||
|
||||
@Column(name = "fee_frequency", nullable = true)
|
||||
@@ -117,26 +128,35 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
@Column(name = "is_free_withdrawal", nullable = false)
|
||||
private boolean enableFreeWithdrawal;
|
||||
|
||||
@Column(name = "free_withdrawal_charge_frequency", nullable = true)
|
||||
@Column(name = "free_withdrawal_charge_frequency")
|
||||
private Integer freeWithdrawalFrequency;
|
||||
|
||||
@Column(name = "restart_frequency", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "restart_frequency")
|
||||
private Integer restartFrequency;
|
||||
|
||||
@Column(name = "restart_frequency_enum", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "restart_frequency_enum")
|
||||
private Integer restartFrequencyEnum;
|
||||
|
||||
@Getter
|
||||
@Column(name = "is_payment_type", nullable = false)
|
||||
private boolean enablePaymentType;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "payment_type_id", nullable = false)
|
||||
private PaymentType paymentType;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "income_or_liability_account_id")
|
||||
private GLAccount account;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "tax_group_id")
|
||||
private TaxGroup taxGroup;
|
||||
@@ -245,12 +265,9 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
this.restartFrequencyEnum = restartFrequencyEnum.getValue();
|
||||
}
|
||||
|
||||
if (enablePaymentType) {
|
||||
if (paymentType != null) {
|
||||
|
||||
this.enablePaymentType = true;
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
if (enablePaymentType && paymentType != null) {
|
||||
this.enablePaymentType = true;
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
} else if (isLoanCharge()) {
|
||||
@@ -279,26 +296,6 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return this.currencyCode;
|
||||
}
|
||||
|
||||
public Integer getChargeTimeType() {
|
||||
return this.chargeTimeType;
|
||||
}
|
||||
|
||||
public Integer getChargeCalculation() {
|
||||
return this.chargeCalculation;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
@@ -351,14 +348,6 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
return ChargeCalculationType.fromInt(this.chargeCalculation).isPercentageOfDisbursementAmount();
|
||||
}
|
||||
|
||||
public BigDecimal getMinCap() {
|
||||
return this.minCap;
|
||||
}
|
||||
|
||||
public BigDecimal getMaxCap() {
|
||||
return this.maxCap;
|
||||
}
|
||||
|
||||
public boolean isEnableFreeWithdrawal() {
|
||||
return this.enableFreeWithdrawal;
|
||||
}
|
||||
@@ -371,22 +360,6 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
return this.freeWithdrawalFrequency;
|
||||
}
|
||||
|
||||
public Integer getRestartFrequency() {
|
||||
return this.restartFrequency;
|
||||
}
|
||||
|
||||
public Integer getRestartFrequencyEnum() {
|
||||
return this.restartFrequencyEnum;
|
||||
}
|
||||
|
||||
public PaymentType getPaymentType() {
|
||||
return this.paymentType;
|
||||
}
|
||||
|
||||
public void setPaymentType(PaymentType paymentType) {
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
private Long getPaymentTypeId() {
|
||||
Long paymentTypeId = null;
|
||||
if (this.paymentType != null) {
|
||||
@@ -450,11 +423,9 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
|
||||
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.loan");
|
||||
}
|
||||
} else if (isClientCharge()) {
|
||||
if (!isAllowedLoanChargeTime()) {
|
||||
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
|
||||
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.client");
|
||||
}
|
||||
} else if (isClientCharge() && !isAllowedLoanChargeTime()) {
|
||||
baseDataValidator.reset().parameter(CHARGE_TIME_PARAM_NAME).value(this.chargeTimeType)
|
||||
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.client");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,7 +618,7 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete is a <i>soft delete</i>. Updates flag on charge so it wont appear in query/report results.
|
||||
* Delete is a <i>soft delete</i>. Updates flag on charge so it won't appear in query/report results.
|
||||
*
|
||||
* Any fields with unique constraints and prepended with id of record.
|
||||
*/
|
||||
@@ -690,14 +661,6 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
|
||||
}
|
||||
|
||||
public Integer getChargePaymentMode() {
|
||||
return this.chargePaymentMode;
|
||||
}
|
||||
|
||||
public Integer getFeeInterval() {
|
||||
return this.feeInterval;
|
||||
}
|
||||
|
||||
public boolean isMonthlyFee() {
|
||||
return ChargeTimeType.fromInt(this.chargeTimeType).isMonthlyFee();
|
||||
}
|
||||
@@ -726,14 +689,6 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
return this.feeFrequency;
|
||||
}
|
||||
|
||||
public GLAccount getAccount() {
|
||||
return this.account;
|
||||
}
|
||||
|
||||
public void setAccount(GLAccount account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Long getIncomeAccountId() {
|
||||
Long incomeAccountId = null;
|
||||
if (this.account != null) {
|
||||
@@ -755,14 +710,6 @@ public class Charge extends AbstractPersistableCustom<Long> {
|
||||
|| ChargeTimeType.fromInt(this.chargeTimeType).equals(ChargeTimeType.TRANCHE_DISBURSEMENT);
|
||||
}
|
||||
|
||||
public TaxGroup getTaxGroup() {
|
||||
return this.taxGroup;
|
||||
}
|
||||
|
||||
public void setTaxGroup(TaxGroup taxGroup) {
|
||||
this.taxGroup = taxGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class FineractErrorDecoder implements ErrorDecoder {
|
||||
|
||||
private String extractValidationErrors(JsonNode rootNode) {
|
||||
JsonNode errorsNode = rootNode.get("errors");
|
||||
if (errorsNode != null && errorsNode.isArray() && errorsNode.size() > 0) {
|
||||
if (errorsNode != null && errorsNode.isArray() && !errorsNode.isEmpty()) {
|
||||
StringBuilder errors = new StringBuilder("Validation errors: ");
|
||||
for (JsonNode error : errorsNode) {
|
||||
String parameterName = extractField(error, "parameterName");
|
||||
|
||||
+8
-16
@@ -77,21 +77,13 @@ public interface ImagesApi {
|
||||
}
|
||||
String ext = fileName.substring(dotPos + 1).toLowerCase();
|
||||
|
||||
switch (ext) {
|
||||
case "jpg":
|
||||
case "jpeg":
|
||||
return "image/jpeg";
|
||||
case "png":
|
||||
return "image/png";
|
||||
case "gif":
|
||||
return "image/gif";
|
||||
case "tif":
|
||||
case "tiff":
|
||||
return "image/tiff";
|
||||
case "pdf":
|
||||
return "application/pdf";
|
||||
default:
|
||||
return "application/octet-stream";
|
||||
}
|
||||
return switch (ext) {
|
||||
case "jpg", "jpeg" -> "image/jpeg";
|
||||
case "png" -> "image/png";
|
||||
case "gif" -> "image/gif";
|
||||
case "tif", "tiff" -> "image/tiff";
|
||||
case "pdf" -> "application/pdf";
|
||||
default -> "application/octet-stream";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -60,8 +60,7 @@ public final class ApiResponseDecoder implements Decoder {
|
||||
}
|
||||
|
||||
private boolean isApiResponseType(Type type) {
|
||||
if (type instanceof ParameterizedType) {
|
||||
ParameterizedType paramType = (ParameterizedType) type;
|
||||
if (type instanceof ParameterizedType paramType) {
|
||||
Type rawType = paramType.getRawType();
|
||||
return rawType == ApiResponse.class;
|
||||
}
|
||||
@@ -69,8 +68,7 @@ public final class ApiResponseDecoder implements Decoder {
|
||||
}
|
||||
|
||||
private Type getApiResponseInnerType(Type type) {
|
||||
if (type instanceof ParameterizedType) {
|
||||
ParameterizedType paramType = (ParameterizedType) type;
|
||||
if (type instanceof ParameterizedType paramType) {
|
||||
Type[] typeArgs = paramType.getActualTypeArguments();
|
||||
if (typeArgs.length > 0) {
|
||||
return typeArgs[0];
|
||||
|
||||
+3
-9
@@ -20,7 +20,9 @@ package org.apache.fineract.infrastructure.cache.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CacheType {
|
||||
|
||||
INVALID(0, "cacheType.invalid"), //
|
||||
@@ -54,15 +56,7 @@ public enum CacheType {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString().replaceAll("_", " ");
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
return name().replace("_", " ");
|
||||
}
|
||||
|
||||
public boolean isNoCache() {
|
||||
|
||||
+3
-4
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.calendar;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
|
||||
public final class CalendarConstants {
|
||||
|
||||
@@ -29,6 +30,7 @@ public final class CalendarConstants {
|
||||
|
||||
public static final String CALENDAR_RESOURCE_NAME = "calendar";
|
||||
|
||||
@Getter
|
||||
public enum CalendarSupportedParameters {
|
||||
|
||||
CALENDAR_ID("id"), //
|
||||
@@ -80,12 +82,9 @@ public final class CalendarConstants {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString().replaceAll("_", " ");
|
||||
return name().replace("_", " ");
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
-43
@@ -20,9 +20,11 @@ package org.apache.fineract.portfolio.calendar.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Getter
|
||||
public enum CalendarFrequencyType {
|
||||
|
||||
INVALID(0, "calendarFrequencyType.invalid"), //
|
||||
@@ -39,16 +41,10 @@ public enum CalendarFrequencyType {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
private static final Map<Integer, CalendarFrequencyType> intToEnumMap = new HashMap<>();
|
||||
@Getter
|
||||
private static int minValue = CalendarFrequencyType.DAILY.value;
|
||||
@Getter
|
||||
private static int maxValue = CalendarFrequencyType.YEARLY.value;
|
||||
|
||||
static {
|
||||
@@ -58,8 +54,7 @@ public enum CalendarFrequencyType {
|
||||
}
|
||||
|
||||
public static CalendarFrequencyType fromInt(final int i) {
|
||||
final CalendarFrequencyType type = intToEnumMap.get(Integer.valueOf(i));
|
||||
return type;
|
||||
return intToEnumMap.get(i);
|
||||
}
|
||||
|
||||
public static CalendarFrequencyType fromString(final String frequencyString) {
|
||||
@@ -82,17 +77,9 @@ public enum CalendarFrequencyType {
|
||||
return frequency;
|
||||
}
|
||||
|
||||
public static int getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public static int getMaxValue() {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString();
|
||||
return name();
|
||||
}
|
||||
|
||||
public boolean isWeekly() {
|
||||
@@ -115,18 +102,13 @@ public enum CalendarFrequencyType {
|
||||
* @return CalendarFrequencyType
|
||||
*/
|
||||
public static CalendarFrequencyType from(final PeriodFrequencyType periodFrequencyType) {
|
||||
switch (periodFrequencyType) {
|
||||
case DAYS:
|
||||
return CalendarFrequencyType.DAILY;
|
||||
case WEEKS:
|
||||
return CalendarFrequencyType.WEEKLY;
|
||||
case MONTHS:
|
||||
return CalendarFrequencyType.MONTHLY;
|
||||
case YEARS:
|
||||
return CalendarFrequencyType.YEARLY;
|
||||
default:
|
||||
return CalendarFrequencyType.INVALID;
|
||||
}
|
||||
return switch (periodFrequencyType) {
|
||||
case DAYS -> CalendarFrequencyType.DAILY;
|
||||
case WEEKS -> CalendarFrequencyType.WEEKLY;
|
||||
case MONTHS -> CalendarFrequencyType.MONTHLY;
|
||||
case YEARS -> CalendarFrequencyType.YEARLY;
|
||||
default -> CalendarFrequencyType.INVALID;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,17 +118,12 @@ public enum CalendarFrequencyType {
|
||||
* @return
|
||||
*/
|
||||
public static PeriodFrequencyType from(final CalendarFrequencyType frequencyType) {
|
||||
switch (frequencyType) {
|
||||
case DAILY:
|
||||
return PeriodFrequencyType.DAYS;
|
||||
case WEEKLY:
|
||||
return PeriodFrequencyType.WEEKS;
|
||||
case MONTHLY:
|
||||
return PeriodFrequencyType.MONTHS;
|
||||
case YEARLY:
|
||||
return PeriodFrequencyType.YEARS;
|
||||
default:
|
||||
return PeriodFrequencyType.INVALID;
|
||||
}
|
||||
return switch (frequencyType) {
|
||||
case DAILY -> PeriodFrequencyType.DAYS;
|
||||
case WEEKLY -> PeriodFrequencyType.WEEKS;
|
||||
case MONTHLY -> PeriodFrequencyType.MONTHS;
|
||||
case YEARLY -> PeriodFrequencyType.YEARS;
|
||||
default -> PeriodFrequencyType.INVALID;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+6
-19
@@ -20,7 +20,9 @@ package org.apache.fineract.portfolio.calendar.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CalendarRemindBy {
|
||||
|
||||
SMS(1, "calendarRemindBy.sms"), //
|
||||
@@ -35,16 +37,10 @@ public enum CalendarRemindBy {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
private static final Map<Integer, CalendarRemindBy> intToEnumMap = new HashMap<>();
|
||||
@Getter
|
||||
private static int minValue;
|
||||
@Getter
|
||||
private static int maxValue;
|
||||
|
||||
static {
|
||||
@@ -65,20 +61,11 @@ public enum CalendarRemindBy {
|
||||
}
|
||||
|
||||
public static CalendarRemindBy fromInt(final int i) {
|
||||
final CalendarRemindBy remindBy = intToEnumMap.get(Integer.valueOf(i));
|
||||
return remindBy;
|
||||
}
|
||||
|
||||
public static int getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public static int getMaxValue() {
|
||||
return maxValue;
|
||||
return intToEnumMap.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString();
|
||||
return name();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-19
@@ -20,7 +20,9 @@ package org.apache.fineract.portfolio.calendar.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CalendarType {
|
||||
|
||||
COLLECTION(1, "calendarType.collection"), //
|
||||
@@ -36,16 +38,10 @@ public enum CalendarType {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
private static final Map<Integer, CalendarType> intToEnumMap = new HashMap<>();
|
||||
@Getter
|
||||
private static int minValue;
|
||||
@Getter
|
||||
private static int maxValue;
|
||||
|
||||
static {
|
||||
@@ -66,21 +62,12 @@ public enum CalendarType {
|
||||
}
|
||||
|
||||
public static CalendarType fromInt(final int i) {
|
||||
final CalendarType type = intToEnumMap.get(Integer.valueOf(i));
|
||||
return type;
|
||||
}
|
||||
|
||||
public static int getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public static int getMaxValue() {
|
||||
return maxValue;
|
||||
return intToEnumMap.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString();
|
||||
return name();
|
||||
}
|
||||
|
||||
public boolean isCollection() {
|
||||
|
||||
+6
-19
@@ -20,8 +20,10 @@ package org.apache.fineract.portfolio.calendar.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Getter
|
||||
public enum CalendarWeekDaysType {
|
||||
|
||||
INVALID(0, "calendarWeekDaysType.invalid"), //
|
||||
@@ -41,16 +43,10 @@ public enum CalendarWeekDaysType {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
private static final Map<Integer, CalendarWeekDaysType> intToEnumMap = new HashMap<>();
|
||||
@Getter
|
||||
private static int minValue = CalendarWeekDaysType.MO.value;
|
||||
@Getter
|
||||
private static int maxValue = CalendarWeekDaysType.SU.value;
|
||||
|
||||
static {
|
||||
@@ -60,21 +56,12 @@ public enum CalendarWeekDaysType {
|
||||
}
|
||||
|
||||
public static CalendarWeekDaysType fromInt(final int i) {
|
||||
final CalendarWeekDaysType type = intToEnumMap.get(Integer.valueOf(i));
|
||||
return type;
|
||||
}
|
||||
|
||||
public static int getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public static int getMaxValue() {
|
||||
return maxValue;
|
||||
return intToEnumMap.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString();
|
||||
return name();
|
||||
}
|
||||
|
||||
public boolean isInvalid() {
|
||||
|
||||
+8
-15
@@ -40,9 +40,7 @@ public final class CalendarEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData calendarEntityType(final CalendarEntityType entityType) {
|
||||
final EnumOptionData optionData = new EnumOptionData(entityType.getValue().longValue(), entityType.getCode(),
|
||||
entityType.toString());
|
||||
return optionData;
|
||||
return new EnumOptionData(entityType.getValue().longValue(), entityType.getCode(), entityType.toString());
|
||||
}
|
||||
|
||||
public static List<EnumOptionData> calendarEntityType(final CalendarEntityType[] entityTypes) {
|
||||
@@ -58,8 +56,7 @@ public final class CalendarEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData calendarType(final CalendarType type) {
|
||||
final EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), type.toString());
|
||||
return optionData;
|
||||
return new EnumOptionData(type.getValue().longValue(), type.getCode(), type.toString());
|
||||
}
|
||||
|
||||
public static List<EnumOptionData> calendarType(final CalendarType[] types) {
|
||||
@@ -75,8 +72,7 @@ public final class CalendarEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData calendarRemindBy(final CalendarRemindBy remindBy) {
|
||||
final EnumOptionData optionData = new EnumOptionData(remindBy.getValue().longValue(), remindBy.getCode(), remindBy.toString());
|
||||
return optionData;
|
||||
return new EnumOptionData(remindBy.getValue().longValue(), remindBy.getCode(), remindBy.toString());
|
||||
}
|
||||
|
||||
public static List<EnumOptionData> calendarRemindBy(final CalendarRemindBy[] remindBys) {
|
||||
@@ -138,16 +134,13 @@ public final class CalendarEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData calendarFrequencyNthDayType(final NthDayType calendarFrequencyNthDayType) {
|
||||
final EnumOptionData optionData = new EnumOptionData(calendarFrequencyNthDayType.getValue().longValue(),
|
||||
calendarFrequencyNthDayType.getCode(), calendarFrequencyNthDayType.toString());
|
||||
return optionData;
|
||||
return new EnumOptionData(calendarFrequencyNthDayType.getValue().longValue(), calendarFrequencyNthDayType.getCode(),
|
||||
calendarFrequencyNthDayType.toString());
|
||||
}
|
||||
|
||||
public static List<EnumOptionData> calendarFrequencyNthDayType() {
|
||||
final List<EnumOptionData> optionDatas = Arrays.asList(calendarFrequencyNthDayType(NthDayType.ONE),
|
||||
calendarFrequencyNthDayType(NthDayType.TWO), calendarFrequencyNthDayType(NthDayType.THREE),
|
||||
calendarFrequencyNthDayType(NthDayType.FOUR), calendarFrequencyNthDayType(NthDayType.LAST),
|
||||
calendarFrequencyNthDayType(NthDayType.ONDAY));
|
||||
return optionDatas;
|
||||
return Arrays.asList(calendarFrequencyNthDayType(NthDayType.ONE), calendarFrequencyNthDayType(NthDayType.TWO),
|
||||
calendarFrequencyNthDayType(NthDayType.THREE), calendarFrequencyNthDayType(NthDayType.FOUR),
|
||||
calendarFrequencyNthDayType(NthDayType.LAST), calendarFrequencyNthDayType(NthDayType.ONDAY));
|
||||
}
|
||||
}
|
||||
|
||||
+7
-11
@@ -208,8 +208,7 @@ public final class CalendarUtils {
|
||||
|
||||
public static LocalDate adjustRecurringDate(final LocalDate recuringDate, final Integer numberOfDays) {
|
||||
if (recuringDate.getDayOfMonth() == 1) {
|
||||
LocalDate adjustedRecurringDate = recuringDate.plusDays(numberOfDays);
|
||||
return adjustedRecurringDate;
|
||||
return recuringDate.plusDays(numberOfDays);
|
||||
}
|
||||
return recuringDate;
|
||||
}
|
||||
@@ -221,9 +220,7 @@ public final class CalendarUtils {
|
||||
final RRule rrule = new RRule(recurringRule);
|
||||
rrule.validate();
|
||||
|
||||
final Recur recur = rrule.getRecur();
|
||||
|
||||
return recur;
|
||||
return rrule.getRecur();
|
||||
} catch (final ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.error("Problem occurred in getICalRecur function", e);
|
||||
@@ -385,7 +382,7 @@ public final class CalendarUtils {
|
||||
final Collection<LocalDate> recurDate = getRecurringDates(recur, seedDate, startDate, date.plusDays(1), 1,
|
||||
isSkipRepaymentonFirstDayOfMonth, numberOfDays);
|
||||
|
||||
return (recurDate == null || recurDate.isEmpty()) ? false : recurDate.contains(date);
|
||||
return recurDate != null && !recurDate.isEmpty() && recurDate.contains(date);
|
||||
}
|
||||
|
||||
public enum DayNameEnum {
|
||||
@@ -585,10 +582,9 @@ public final class CalendarUtils {
|
||||
if (isValidRecurringDate(recur, seedDate, oldRepaymentDate, isSkipRepaymentOnFirstDayOfMonth, numberOfDays)) {
|
||||
return oldRepaymentDate;
|
||||
}
|
||||
LocalDate nextRepaymentDate = getNextRepaymentMeetingDate(recurringRule, seedDate, oldRepaymentDate, loanRepaymentInterval,
|
||||
frequency, workingDays, isSkipRepaymentOnFirstDayOfMonth, numberOfDays);
|
||||
|
||||
return nextRepaymentDate;
|
||||
return getNextRepaymentMeetingDate(recurringRule, seedDate, oldRepaymentDate, loanRepaymentInterval, frequency, workingDays,
|
||||
isSkipRepaymentOnFirstDayOfMonth, numberOfDays);
|
||||
}
|
||||
|
||||
public static LocalDate getNextRepaymentMeetingDate(final String recurringRule, final LocalDate seedDate, final LocalDate repaymentDate,
|
||||
@@ -701,10 +697,10 @@ public final class CalendarUtils {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < calendarTypeOptions.size() - 1; i++) {
|
||||
sb.append(calendarTypeOptions.get(i).toString() + ",");
|
||||
sb.append(calendarTypeOptions.get(i).toString()).append(",");
|
||||
}
|
||||
|
||||
sb.append(calendarTypeOptions.get(calendarTypeOptions.size() - 1).toString());
|
||||
sb.append(calendarTypeOptions.getLast().toString());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
+8
-23
@@ -18,9 +18,12 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.client.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Enum representation of client identifier status states.
|
||||
*/
|
||||
@Getter
|
||||
public enum ClientIdentifierStatus {
|
||||
|
||||
INACTIVE(100, "clientIdentifierStatusType.inactive"), //
|
||||
@@ -31,17 +34,11 @@ public enum ClientIdentifierStatus {
|
||||
private final String code;
|
||||
|
||||
public static ClientIdentifierStatus fromInt(final Integer statusValue) {
|
||||
|
||||
ClientIdentifierStatus enumeration = ClientIdentifierStatus.INVALID;
|
||||
switch (statusValue) {
|
||||
case 100:
|
||||
enumeration = ClientIdentifierStatus.INACTIVE;
|
||||
break;
|
||||
case 200:
|
||||
enumeration = ClientIdentifierStatus.ACTIVE;
|
||||
break;
|
||||
}
|
||||
return enumeration;
|
||||
return switch (statusValue) {
|
||||
case 100 -> ClientIdentifierStatus.INACTIVE;
|
||||
case 200 -> ClientIdentifierStatus.ACTIVE;
|
||||
default -> ClientIdentifierStatus.INVALID;
|
||||
};
|
||||
}
|
||||
|
||||
ClientIdentifierStatus(final Integer value, final String code) {
|
||||
@@ -49,18 +46,6 @@ public enum ClientIdentifierStatus {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
// public boolean hasStateOf(final ClientIdentifierStatus state) {
|
||||
// return this.value.equals(state.getValue());
|
||||
// }
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public boolean isInactive() {
|
||||
return this.value.equals(ClientIdentifierStatus.INACTIVE.getValue());
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public enum ConditionType {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toString().replace("_", " ");
|
||||
return name().replace("_", " ");
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
|
||||
+4
-5
@@ -18,6 +18,9 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.collateralmanagement.api;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CollateralManagementJsonInputParams {
|
||||
|
||||
NAME("name"), //
|
||||
@@ -39,11 +42,7 @@ public enum CollateralManagementJsonInputParams {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().replaceAll("_", " ");
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
return name().replace("_", " ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-4
@@ -141,12 +141,10 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
|
||||
|
||||
// If the Loan is not Active yet or is cancelled (rejected or withdrawn), return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved() || loan.isCancelled()) {
|
||||
if (loan.getLoanProduct() != null && !loan.getLoanProduct().isAllowApprovedDisbursedAmountsOverApplied()) {
|
||||
return collectionData;
|
||||
} else {
|
||||
if (loan.getLoanProduct() == null || loan.getLoanProduct().isAllowApprovedDisbursedAmountsOverApplied()) {
|
||||
collectionData.setAvailableDisbursementAmountWithOverApplied(calculateAvailableDisbursementAmountWithOverApplied(loan));
|
||||
return collectionData;
|
||||
}
|
||||
return collectionData;
|
||||
}
|
||||
|
||||
final List<LoanDelinquencyAction> savedDelinquencyList = retrieveLoanDelinquencyActions(loanId);
|
||||
|
||||
+5
-7
@@ -42,7 +42,7 @@ import org.mockito.MockitoAnnotations;
|
||||
/**
|
||||
* Test class for {@link CreateChargeByLoanExternalIdCommandStrategy}.
|
||||
*/
|
||||
public class CreateChargeByLoanExternalIdCommandStrategyTest {
|
||||
class CreateChargeByLoanExternalIdCommandStrategyTest {
|
||||
|
||||
/**
|
||||
* Command arguments provider.
|
||||
@@ -50,7 +50,7 @@ public class CreateChargeByLoanExternalIdCommandStrategyTest {
|
||||
* @return command argument
|
||||
*/
|
||||
private static Stream<Arguments> provideCommandParameters() {
|
||||
return Stream.of(Arguments.of(null, 0), Arguments.of("adjustment", 1));
|
||||
return Stream.of(Arguments.of((Object) null), Arguments.of("adjustment"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,12 +58,10 @@ public class CreateChargeByLoanExternalIdCommandStrategyTest {
|
||||
*
|
||||
* @param command
|
||||
* the command to pass
|
||||
* @param noOfArguments
|
||||
* the number of arguments
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideCommandParameters")
|
||||
public void testExecuteSuccessScenario(final String command, final int noOfArguments) {
|
||||
void testExecuteSuccessScenario(final String command) {
|
||||
final TestContext testContext = new TestContext();
|
||||
final String loanExternalId = UUID.randomUUID().toString();
|
||||
final BatchRequest batchRequest = getBatchRequest(loanExternalId, command);
|
||||
@@ -98,10 +96,10 @@ public class CreateChargeByLoanExternalIdCommandStrategyTest {
|
||||
if (StringUtils.isNotBlank(command)) {
|
||||
relativeUrl = relativeUrl + String.format("?command=%s", command);
|
||||
}
|
||||
br.setRequestId(Long.valueOf(RandomStringUtils.randomNumeric(5)));
|
||||
br.setRequestId(Long.valueOf(RandomStringUtils.secure().nextNumeric(5)));
|
||||
br.setRelativeUrl(relativeUrl);
|
||||
br.setMethod(HttpMethod.POST);
|
||||
br.setReference(Long.valueOf(RandomStringUtils.randomNumeric(5)));
|
||||
br.setReference(Long.valueOf(RandomStringUtils.secure().nextNumeric(5)));
|
||||
br.setBody("{}");
|
||||
|
||||
return br;
|
||||
|
||||
Reference in New Issue
Block a user