• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reflexion and enum

 
mark smith
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i use this code



getGlass return an enum

is there a way to do that with reflexion?

thanks
 
Henry Wong
author
Marshal
Pie
Posts: 21489
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a way to do that with reflexion?


Not sure what you are asking. Can you elaborate? enums are just objects, so the reflection library should work for them too.

Henry
 
mark smith
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this line of code is in a class X who extends Y



this class Y have



Glass is an enum

so my question is how to be able to do the same thing then



but with reflexion?

i tried



but i'm not able to access the field (tickness)

any idea?
 
Henry Wong
author
Marshal
Pie
Posts: 21489
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark smith wrote:
but i'm not able to access the field (tickness)

any idea?


Try...




BTW, if you know the exact method to execute, and the exact field to get, why do you need reflection? The way you are doing it now is much easier than using reflection.

Henry
 
mark smith
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Henry Wong that work...

the method can change... not the field...
 
Henry Wong
author
Marshal
Pie
Posts: 21489
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark smith wrote:thanks Henry Wong that work...

the method can change... not the field...


If the field doesn't change, then there is no reason to use reflection to get it... you can simply cast and dereference it.



Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic