2

I have following problem:

need to use enum in my java code, since I'll have to ask in my business logic things like if(someting == enumname.VALUE_ENUM){... but I don't have all the enum types at the compile time - that is I have them but there is too many enum types that I won't use in my business logic except in cases where I need to loop over all of the enum values for(enumname var : enumname.value()){...

This seems more like the real entity then (since in DB it has an Id and a lot more properties), but it looks ugly to type if(something == object.getByString("VALUE_ENUM"))

Is there some more pedant way of doing it?

0

found solution here if anybody needs it...

http://niceideas.ch/roller2/badtrash/entry/java_create_enum_instances_dynamically

and this is the one with compile-time solution:

https://bojanv55.wordpress.com/2015/05/25/java-dynamic-enums/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.