package com.livingworld.core.services;

import com.livingworld.core.simulation.RegionManager;
import com.livingworld.core.simulation.SimulationManager;
import com.livingworld.events.LivingWorldEventBus;
import com.livingworld.modules.ModuleRegistry;

/**
 * Central list of built-in service keys for the Living World core services.
 *
 * <p>This class is a final utility class with a private constructor. Each field
 * defines a {@link ServiceKey} that will be used to register and retrieve core
 * services once their implementations exist.</p>
 *
 * <p>Only CONFIG can use its real type (ConfigService) since that interface already exists.
 * All other keys currently use Object as a placeholder with TODO comments pointing to the
 * relevant milestone where the actual service implementation will be created.</p>
 *
 * <h3>Migration Guide</h3>
 * <p>As each service interface is created during its milestone, migrate its key from
 * {@code Object} to the real type. For example:</p>
 * <pre>{@code
 * // Before (placeholder):
 * @SuppressWarnings("unchecked")
 * public static final ServiceKey<Object> REGIONS = new ServiceKey<>("regions", Object.class);
 *
 * // After (typed - when RegionManager interface is created):
 * public static final ServiceKey<RegionManager> REGIONS = new ServiceKey<>("regions", RegionManager.class);
 * }</pre>
 * <p>Benefits of typed keys: compile-time type safety, no unchecked casts in caller code,
 * and the {@link ServiceRegistry#find(ServiceKey)} method returns {@code Optional<T>} with
 * the correct type.</p>
 */
public final class CoreServices {

    private CoreServices() {
        // Utility class — no instantiation allowed.
    }

    /** ConfigService key — interface already exists. */
    public static final ServiceKey<ConfigService> CONFIG = new ServiceKey<>("config", ConfigService.class);

    public static final ServiceKey<RegionManager> REGIONS =
            new ServiceKey<>("regions", RegionManager.class);

    public static final ServiceKey<SimulationManager> SIMULATION =
            new ServiceKey<>("simulation", SimulationManager.class);

    public static final ServiceKey<PersistenceService> PERSISTENCE =
            new ServiceKey<>("persistence", PersistenceService.class);

    public static final ServiceKey<LivingWorldEventBus> EVENTS =
            new ServiceKey<>("events", LivingWorldEventBus.class);

    public static final ServiceKey<ModuleRegistry> MODULES =
            new ServiceKey<>("modules", ModuleRegistry.class);

    public static final ServiceKey<TimeService> TIME =
            new ServiceKey<>("time", TimeService.class);

    // TODO: Replace Object with DebugService when created (Milestone 15)
    @SuppressWarnings("unchecked")
    public static final ServiceKey<Object> DEBUG = new ServiceKey<>("debug", Object.class);

    // TODO: Replace Object with HistoryService when created (post-Volume 1)
    @SuppressWarnings("unchecked")
    public static final ServiceKey<Object> HISTORY = new ServiceKey<>("history", Object.class);
}
