package squirrel;

import java.util.*;

import models.UserModel;

public class ModelManager {
    private static final Map<Class<? extends Model>, Model> models = new HashMap<>();

    public static void initializeModels() {
        List<Class<? extends Model>> modelClasses = Arrays.asList(
            UserModel.class
        );
        for (Class<? extends Model> clazz : modelClasses) {
            try {
                Model instance = Model.initializeClassMode(clazz);
                models.put(clazz, instance);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static <T extends Model> T get(Class<T> clazz) {
        Model instance = models.get(clazz);
        if (instance == null) {
            throw new IllegalStateException("Model not initialized: " + clazz.getSimpleName());
        }
        return clazz.cast(instance);
    }
}
