package de.effigenix.domain.usermanagement;

import java.util.UUID;

/**
 * Value Object representing a User's unique identifier.
 * Immutable and self-validating.
 */
public record UserId(String value) {

    public UserId {
        if (value == null || value.isBlank()) {
            throw new IllegalArgumentException("UserId cannot be null or empty");
        }
    }

    /**
     * Generates a new random UserId.
     */
    public static UserId generate() {
        return new UserId(UUID.randomUUID().toString());
    }

    /**
     * Creates a UserId from a string value.
     */
    public static UserId of(String value) {
        return new UserId(value);
    }
}
