package com.livingworld.modules;

/**
 * Minimal placeholder for a historical record entry.
 *
 * <p>TODO: This class is temporary and will be moved to an appropriate package
 * (e.g. {@code com.livingworld.core} or {@code com.livingworld.data}) once the
 * data layer design is finalised.</p>
 */
public final class HistoryRecord {

    private final String moduleId;
    private final long tick;
    private final String recordType;
    private final String data;

    /**
     * Creates a new HistoryRecord.
     *
     * @param moduleId  the module that generated this record (must not be null or blank)
     * @param tick      the simulation tick at which this record was created
     * @param recordType the type/category of this record (may be null, defaults to "generic")
     * @param data       free-form data string for this record (may be null, defaults to empty)
     */
    public HistoryRecord(String moduleId, long tick, String recordType, String data) {
        if (moduleId == null || moduleId.isBlank()) {
            throw new IllegalArgumentException("moduleId must not be null or blank");
        }

        this.moduleId = moduleId;
        this.tick = tick;
        this.recordType = recordType != null ? recordType : "generic";
        this.data = data != null ? data : "";
    }

    /**
     * Returns the module ID that generated this record.
     */
    public String moduleId() {
        return moduleId;
    }

    /**
     * Returns the simulation tick at which this record was created.
     */
    public long tick() {
        return tick;
    }

    /**
     * Returns the type/category of this record.
     */
    public String recordType() {
        return recordType;
    }

    /**
     * Returns the free-form data associated with this record.
     */
    public String data() {
        return data;
    }

    @Override
    public String toString() {
        return "HistoryRecord{moduleId=" + moduleId + ", tick=" + tick +
               ", recordType='" + recordType + "', data='" + data + "'}";
    }
}