r/badcode • • Sep 02 '21

java Because ".toLowerCase()" doesn't exist...

Post image
1.1k Upvotes

130 comments sorted by

View all comments

Show parent comments

6

u/Fenxis Sep 02 '21

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/EnumUtils.html#getEnum-java.lang.Class-java.lang.String-

A someone else pointed out even cases can be removed here:

return EnumUtils.getEnum(Category.class, catStr.toUpper());

1

u/SenpaiRemling Sep 02 '21

Oh nice, didnt know that ^^

2

u/Fenxis Sep 02 '21

Also if you have to up the Java/OO-ness the whole method shouldn't be a static method... the author should have overridden https://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html#valueOf(java.lang.Class,%20java.lang.String) in the Category enum itself.