package click.kamil.springstatemachineexporter.analysis.model;

/**
 * Synthetic trigger markers for persistence/lifecycle operations that do not fire
 * {@code sendEvent} transitions (e.g. {@code StateMachinePersister.restore(...)}).
 */
public final class LifecycleTriggerMarkers {

    public static final String PREFIX = "[LIFECYCLE:";

    private LifecycleTriggerMarkers() {
    }

    public static boolean isLifecycle(String event) {
        return event != null && event.startsWith(PREFIX) && event.endsWith("]");
    }

    public static String lifecycleType(String event) {
        if (!isLifecycle(event)) {
            return null;
        }
        return event.substring(PREFIX.length(), event.length() - 1);
    }

    public static String displayLabel(String event) {
        String type = lifecycleType(event);
        if (type == null) {
            return event;
        }
        return switch (type.toUpperCase()) {
            case "RESTORE" -> "Restore persisted state";
            case "RESET" -> "Reset state machine";
            default -> "Lifecycle: " + type.toLowerCase();
        };
    }
}
