FINERACT-2421: Refractor redundant and some deprecated code as per new Java 21 style (Phase 5)
This commit is contained in:
+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() {
|
||||
|
||||
Reference in New Issue
Block a user