package com.petshop.backend;

import java.net.URL;

final class RuntimeClasspathValidator {

    private RuntimeClasspathValidator() {
    }

    static void validate() {
        if (!resourceExists("application.yml")) {
            throw new IllegalStateException("Backend resources are missing from the runtime classpath. Reimport the Maven project in IntelliJ and run the shared Maven run configuration.");
        }
        if (!resourceExists("db/migration/V1__target_baseline.sql")) {
            throw new IllegalStateException("Flyway migration files are missing from the runtime classpath. Reimport the Maven project in IntelliJ and run the shared Maven run configuration.");
        }
    }

    private static boolean resourceExists(String path) {
        ClassLoader classLoader = RuntimeClasspathValidator.class.getClassLoader();
        URL resource = classLoader.getResource(path);
        return resource != null;
    }
}
