• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set string value parameters in Annotaions without hardcoding  RSS feed

 
Theodore David Williams
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take the following made up example:


The name parameter can only be assigned a constant value. However I do not like hard-coding this name. What if I need to use the same name somewhere else? I would have to hard code it again and then possibly introduce a bug if one hard-coded value was updated but not the other.

Is the only solution to use a constant string variable?

What if he example was more complex and I have several of the same annotations with each string a little different but all fit into the same "group". Like a list of enumerated values.



Seems like a good solution would be to create an Enum called 'Color' but again the toString() method of enum does not return a constant right.

So now I am back to a string but in this case a constant list of strings?

Anyone have any good advice??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!