package fr.pandacube.java.util.db; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import fr.pandacube.java.util.db2.sql_tools.DBConnection; /** * ORM = Object-Relational Mapping
* Liste des tables avec leur classes : * * @author Marc Baloup * */ public final class ORM { private static List> tables = new ArrayList>(); /* package */ static DBConnection connection; public synchronized static void init(DBConnection conn) { try { connection = conn; /* * Les tables SQL sont à instancier ici ! */ tables.add(new LoginHistoryTable()); tables.add(new ModoHistoryTable()); tables.add(new MPGroupTable()); tables.add(new MPGroupUserTable()); tables.add(new MPMessageTable()); tables.add(new OnlineShopHistoryTable()); tables.add(new PlayerTable()); tables.add(new PlayerIgnoreTable()); tables.add(new ShopStockTable()); tables.add(new StaffTicketTable()); } catch (SQLException e) { e.printStackTrace(); } } public synchronized static > T getTable(Class c) { if (c == null) return null; for (SQLTable table : tables) { if (c.isAssignableFrom(table.getClass())) { return c.cast(table); } } return null; } private ORM() { } // rend la classe non instanciable }