How do I get the actual Enum value from a PsiEnumConstant instance?

I've got a PsiEnumConstant but I'd need the actual value it represents (MyEnum.EXAMPLE).  How do I convert it?

4 comments
Comment actions Permalink

Hello Brian,

What exactly do you mean by the value? The enum constant is the value.

I've got a PsiEnumConstant but I'd need the actual value it represents
(MyEnum.EXAMPLE).  How do I convert it?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

I want an Object of type MyEnum. What I did was call MyEnum.valueOf(...) but I was wondering if there was a better way.

0
Comment actions Permalink

Hello Brian,

PSI is a representation of the source code; it doesn't have any direct connection
to classes that have been compiled from the source code, and by default IDEA
doesn't load the compiled classes at all.

I want an Object of type MyEnum. What I did was call
MyEnum.valueOf(...) but I was wondering if there was a better way.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks for clarifying, that's what I came to suspect after asking the question.

0

Please sign in to leave a comment.