Java reflection - non case sensitive Class.forName() in a package -
the same question has answers fields
, methods
, both suggesting iterate on existing members , lower-case comparing names. classes
different in can't [easily] iterate on classes in package.
my java application instantiates objects according given input 3rd party - non-case-sensitive - application, , fails when case wrong. since java won't allow classes same name , different case in 1 package, guess there should simple way class
object without having exact case.
i want avoid multiple if
/else if
since add classes package time. try
ing case possibilities out of question (since o(2^n)).
so, how should go it?
solution:
as suggested in @ireeder's answer (thanks @assylias), ignored standard java conventions , name classes lowercase. way can call class.forname lower case version of input.
Comments
Post a Comment