package com.correx.core.utils

import kotlinx.serialization.Serializable
import java.util.UUID

@JvmInline
@Serializable
value class TypeId(val value: String) {
    init {
        require(value.isNotBlank()) { "id must not be blank" }
        require(value.trim() == value) { "id must not contain leading/trailing whitespace" }
    }

    override fun toString(): String = value

    companion object {
        /** Sentinel value used when no real stage/entity is available. */
        val NONE = TypeId("none")

        /** Create a new random ID using a UUID string. */
        fun random(): TypeId = TypeId(UUID.randomUUID().toString())
    }
}
