lundi 3 juillet 2017

Creating java objects based on their type

I have a set of data objects, which correspond to rows in RDMS table, as in ClassA -> Rows of TableA ClassB -> Rows of TableB . . . ClassZ -> Rows of TableZ I am fetching these records using JDBC and creating objects from the result set(Please note that the result set can be huge) I have custom parsers for each class i.e parseClassA(), parseClassB()....parseClassZ(), currently i am having a function with a huge switch statement which determines the type of the class like switch(classType) and gives me an object of the corresponding class, i want to eliminate this switch statement, which is the optimal way to do this?

Aucun commentaire:

Enregistrer un commentaire