Justin Filmer wrote:Thanks.
I have an Array of Objects, and I need to quickly print out and log (to a text file) all of the same instance properties for the Objects. I don't want to have to create a new method for each since I know specs are going to change and more instance variables will be added to the Class. I'd much rather call the same method with a different argument.
In my humble opinion, you are not thinking in an object oriented matter.
You should split out the Color to a class of its own, maybe even an Enum if there is only to be a fixed number of colors. Also, the Skills/TrainedAreas could be a class of its own. I can bet quite big bucks that the later will have a training level later on...
Regarding using one method to get them all (aka the method of the ring) or multiple methods there are some different ways to go:
1. Live with the fact that you have to implement a new method for each attribute type.
2. Rely on reflection and make a nice bean centric framework.
3. Look into some sort of persistence layer and use that to search by attribute.
4. Delegate to the class holding the attribute to return is based on an interface that allows you to query by attribute name.
5. A combination of the previous four.