mercredi 13 juillet 2016

How to build a java factory using keys

I am trying to build a command parser which receives a block of data and parses that data into an instance of a specific command. This is basically then a factory whereby the instance returned from the factory is based on a key.

There are a lot of discussions on how to build factories in java, some very direct, some using various bits of generics and reflections; but I have had no luck finding a specific implementation that fits what I am trying to accomplish. I did however find bits and pieces that relate to what I am trying to accomplish and so I have put those together into an answer which is the first response below. Is this a good response or am I overlooking something simpler or something more complete?

Aucun commentaire:

Enregistrer un commentaire