Skip to content

Commit 4f8a23c

Browse files
authored
Merge pull request #5579
FINERACT-2515: Fix the TODO comments in the Apache Fineract Code
2 parents df11055 + 096ef66 commit 4f8a23c

45 files changed

Lines changed: 190 additions & 350 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fineract-core/src/main/java/org/apache/fineract/portfolio/accountdetails/domain/AccountType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ public String getName() {
8181
return name().toLowerCase();
8282
}
8383

84-
public boolean isInvalid() {
85-
return this.value.equals(AccountType.INVALID.getValue());
86-
}
87-
8884
public boolean isIndividualAccount() {
8985
return this.value.equals(AccountType.INDIVIDUAL.getValue());
9086
}

fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/Calendar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ private static String constructRecurrence(final CalendarFrequencyType frequencyT
526526
if (frequencyType.isWeekly()) {
527527
if (repeatsOnDay != null) {
528528
final CalendarWeekDaysType weekDays = CalendarWeekDaysType.fromInt(repeatsOnDay);
529-
if (!weekDays.isInvalid()) {
529+
if (weekDays != CalendarWeekDaysType.INVALID) {
530530
recurrenceBuilder.append(";BYDAY=");
531531
recurrenceBuilder.append(weekDays.toString().toUpperCase(java.util.Locale.ROOT));
532532
}
@@ -541,12 +541,12 @@ private static String constructRecurrence(final CalendarFrequencyType frequencyT
541541
} else if (repeatsOnNthDayOfMonth != null && repeatsOnDay != null
542542
&& !repeatsOnDay.equals(CalendarWeekDaysType.INVALID.getValue())) {
543543
final NthDayType nthDay = NthDayType.fromInt(repeatsOnNthDayOfMonth);
544-
if (!nthDay.isInvalid()) {
544+
if (nthDay != NthDayType.INVALID) {
545545
recurrenceBuilder.append(";BYSETPOS=");
546546
recurrenceBuilder.append(nthDay.getValue());
547547
}
548548
final CalendarWeekDaysType weekday = CalendarWeekDaysType.fromInt(repeatsOnDay);
549-
if (!weekday.isInvalid()) {
549+
if (weekday != CalendarWeekDaysType.INVALID) {
550550
recurrenceBuilder.append(";BYDAY=");
551551
recurrenceBuilder.append(weekday.toString().toUpperCase(java.util.Locale.ROOT));
552552
}

fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarFrequencyType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ public boolean isMonthly() {
9090
return this.value.equals(CalendarFrequencyType.MONTHLY.value);
9191
}
9292

93-
public boolean isInvalid() {
94-
return this.value.equals(CalendarFrequencyType.INVALID.value);
95-
}
96-
9793
/**
9894
* To convert from period frequency type tp calendar frequency type. This method requires code refactoring.
9995
*

fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/domain/CalendarWeekDaysType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ public String toString() {
6464
return name();
6565
}
6666

67-
public boolean isInvalid() {
68-
return this.value.equals(CalendarWeekDaysType.INVALID.value);
69-
}
70-
7167
public static CalendarWeekDaysType fromString(final String weekDayString) {
7268
CalendarWeekDaysType weekDay = CalendarWeekDaysType.INVALID;
7369

fineract-core/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarEnumerations.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static EnumOptionData calendarFrequencyType(final int id) {
8989

9090
public static EnumOptionData calendarFrequencyType(final CalendarFrequencyType calendarFrequencyType) {
9191
EnumOptionData optionData = null;
92-
if (!calendarFrequencyType.isInvalid()) {
92+
if (calendarFrequencyType != CalendarFrequencyType.INVALID) {
9393
optionData = new EnumOptionData(calendarFrequencyType.getValue().longValue(), calendarFrequencyType.getCode(),
9494
calendarFrequencyType.toString());
9595
}
@@ -99,7 +99,7 @@ public static EnumOptionData calendarFrequencyType(final CalendarFrequencyType c
9999
public static List<EnumOptionData> calendarFrequencyType(final CalendarFrequencyType[] calendarFrequencyTypes) {
100100
final List<EnumOptionData> optionDatas = new ArrayList<>();
101101
for (final CalendarFrequencyType calendarFrequencyType : calendarFrequencyTypes) {
102-
if (!calendarFrequencyType.isInvalid()) {
102+
if (calendarFrequencyType != CalendarFrequencyType.INVALID) {
103103
optionDatas.add(calendarFrequencyType(calendarFrequencyType));
104104
}
105105
}
@@ -112,7 +112,7 @@ public static EnumOptionData calendarWeekDaysType(final int id) {
112112

113113
public static EnumOptionData calendarWeekDaysType(final CalendarWeekDaysType calendarWeekDaysType) {
114114
EnumOptionData optionData = null;
115-
if (!calendarWeekDaysType.isInvalid()) {
115+
if (calendarWeekDaysType != CalendarWeekDaysType.INVALID) {
116116
optionData = new EnumOptionData(calendarWeekDaysType.getValue().longValue(), calendarWeekDaysType.getCode(),
117117
calendarWeekDaysType.toString());
118118
}
@@ -122,7 +122,7 @@ public static EnumOptionData calendarWeekDaysType(final CalendarWeekDaysType cal
122122
public static List<EnumOptionData> calendarWeekDaysType(final CalendarWeekDaysType[] calendarWeekDaysTypes) {
123123
final List<EnumOptionData> optionDatas = new ArrayList<>();
124124
for (final CalendarWeekDaysType calendarWeekDaysType : calendarWeekDaysTypes) {
125-
if (!calendarWeekDaysType.isInvalid()) {
125+
if (calendarWeekDaysType != CalendarWeekDaysType.INVALID) {
126126
optionDatas.add(calendarWeekDaysType(calendarWeekDaysType));
127127
}
128128
}

fineract-core/src/main/java/org/apache/fineract/portfolio/common/domain/ConditionType.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ public String getCode() {
6868
return this.code;
6969
}
7070

71-
// TODO: why not just use the enum values... just more boilerplate code here!!
72-
public boolean isInvalid() {
73-
return ConditionType.INVALID.getValue().equals(this.value);
74-
}
75-
7671
// TODO: do we really need this?!?
7772
public static Object[] integerValues() {
7873
return Arrays.stream(values()).filter(value -> !INVALID.equals(value)).map(value -> value.value).toList().toArray();

fineract-core/src/main/java/org/apache/fineract/portfolio/common/domain/NthDayType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ public static NthDayType fromInt(final Integer frequency) {
7777
return repaymentFrequencyNthDayType;
7878
}
7979

80-
public boolean isInvalid() {
81-
return this.value.equals(NthDayType.INVALID.value);
82-
}
83-
8480
public boolean isLastDay() {
8581
return this.value.equals(NthDayType.LAST.value);
8682
}

fineract-core/src/main/java/org/apache/fineract/portfolio/common/domain/PeriodFrequencyType.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ public boolean isDaily() {
8686
return this.equals(DAYS);
8787
}
8888

89-
// TODO: why not just use the enum values... just more boilerplate code here!!
90-
public boolean isWholeTerm() {
91-
return this.equals(WHOLE_TERM);
92-
}
93-
94-
// TODO: why not just use the enum values... just more boilerplate code here!!
95-
public boolean isInvalid() {
96-
return this.equals(INVALID);
97-
}
98-
9989
// TODO: do we really need this?!?
10090
public static Object[] integerValues() {
10191
return Arrays.stream(values()).filter(value -> !INVALID.equals(value)).map(value -> value.value).toList().toArray();

fineract-core/src/main/java/org/apache/fineract/portfolio/common/service/CommonEnumerations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static EnumOptionData conditionType(final ConditionType type, final Strin
112112
public static List<EnumOptionData> conditionType(final ConditionType[] conditionTypes, final String codePrefix) {
113113
final List<EnumOptionData> optionDatas = new ArrayList<>();
114114
for (final ConditionType conditionType : conditionTypes) {
115-
if (!conditionType.isInvalid()) {
115+
if (conditionType != ConditionType.INVALID) {
116116
optionDatas.add(conditionType(conditionType, codePrefix));
117117
}
118118
}

fineract-core/src/main/java/org/apache/fineract/portfolio/savings/DepositAccountOnClosureType.java

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,7 @@ public static DepositAccountOnClosureType fromInt(final Integer v) {
5555
};
5656
}
5757

58-
// TODO: why not just use the enum values... just more boilerplate code here!!
59-
public boolean isWithdarwDeposit() {
60-
return this.equals(WITHDRAW_DEPOSIT);
61-
}
62-
63-
// TODO: why not just use the enum values... just more boilerplate code here!!
64-
public boolean isTransferToSavings() {
65-
return this.equals(TRANSFER_TO_SAVINGS);
66-
}
67-
68-
// TODO: why not just use the enum values... just more boilerplate code here!!
69-
public boolean isReinvest() {
70-
return this.equals(REINVEST_PRINCIPAL_AND_INTEREST) || this.equals(REINVEST_PRINCIPAL_ONLY);
71-
}
72-
73-
// TODO: why not just use the enum values... just more boilerplate code here!!
74-
public boolean isReinvestPrincipal() {
75-
return this.equals(REINVEST_PRINCIPAL_ONLY);
76-
}
77-
78-
// TODO: why not just use the enum values... just more boilerplate code here!!
79-
public boolean isReinvestPrincipalAndInterest() {
80-
return this.equals(REINVEST_PRINCIPAL_AND_INTEREST);
81-
}
82-
83-
// TODO: why not just use the enum values... just more boilerplate code here!!
84-
public boolean isInvalid() {
85-
return this.equals(INVALID);
86-
}
87-
88-
// TODO: do we really need this?!?
89-
public static Object[] integerValues() {
90-
return Arrays.stream(values()).filter(value -> !INVALID.equals(value)).map(value -> value.value).toList().toArray();
58+
public static Integer[] integerValues() {
59+
return Arrays.stream(values()).filter(v -> v != INVALID).map(v -> v.value).toArray(Integer[]::new);
9160
}
9261
}

0 commit comments

Comments
 (0)