vidakovic commented on code in PR #3563:
URL: https://github.com/apache/fineract/pull/3563#discussion_r1442547634
##########
fineract-core/src/main/java/org/apache/fineract/accounting/glaccount/domain/GLAccountType.java:
##########
@@ -86,9 +82,25 @@ public static EnumOptionData fromString(String accountType) {
}
}
- public static GLAccountType fromInt(final int i) {
- final GLAccountType type = intToEnumMap.get(Integer.valueOf(i));
- return type;
+ public static GLAccountType fromInt(final Integer v) {
Review Comment:
Well... the way the enums are handled is wrong on a whole different level.
If you think that putting them in a map this makes it better... I don't think
so. My argument here is: why use enums in the first place? If, in the end, we
compare against integer values... the complaint here - I guess with
"hardcoding" you mean the switch statement - goes further... why all the
additional functions? Like `isInvalid()` etc. etc. ... everytime you add a new
enum value a new function needs to be added... this kind of defeats the whole
purpose of an enum. I investigated a bunch of these implementations (someone
started this strategy 10 years ago and then many followed... unfortunately) and
pretty much all of the enums have this flaw.
I'd say not relevant for the release. Let's decide then on a strategy and
put this in the next release.รถ
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]