package com.cameleer.server.core.runtime;

public enum RuntimeType {
    AUTO,
    SPRING_BOOT,
    QUARKUS,
    PLAIN_JAVA,
    NATIVE;

    /** Parse from containerConfig string value, case-insensitive. Returns null if unrecognized. */
    public static RuntimeType fromString(String value) {
        if (value == null || value.isBlank()) return AUTO;
        return switch (value.toLowerCase().replace("-", "_")) {
            case "auto" -> AUTO;
            case "spring_boot" -> SPRING_BOOT;
            case "quarkus" -> QUARKUS;
            case "plain_java" -> PLAIN_JAVA;
            case "native" -> NATIVE;
            default -> null;
        };
    }

    /** Lowercase kebab-case for JSON serialization. */
    public String toConfigValue() {
        return name().toLowerCase().replace("_", "-");
    }
}
