lundi 26 avril 2021

Java reflexation get all classes within constrains

Im trying to make a generic instance mapper from an SQLite DB to my project logic layer. Each entry in the mapper is an instance of some class "DAL< name >" for example "DALProduct" all in the same package that extends class "DALObject" with the following structure:

public abstract class DALObject{
  static String getCreate();
  ... //other logic
}

Using reflexation I can easily call the getCreate method on each class and get what I need from it. The issue is that I dont know how many child classes DALObject will have and i want a mapper that won't need to be touched when a new one is added.

I know that you can get all child classes of DALObjects that have been loaded but I run this code at the very start of my program before I load any of the classes.

Any ideas? I have a pretty big constraint case so maybe I can somehow hack it together.





Aucun commentaire:

Enregistrer un commentaire