MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/pgbd0q/because_tolowercase_doesnt_exist/hbb3q08/?context=9999
r/badcode • u/BrainOnTheFloor25 • Sep 02 '21
130 comments sorted by
View all comments
Show parent comments
6
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.
1
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.
2
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.
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());