import java.time.LocalDate;

/**
 * Representasi satu tugas sebagai resource API.
 * Invarian dasar dijaga compact constructor sehingga objek Tugas tidak pernah
 * berada dalam keadaan tidak sah, apa pun asal datanya (kode atau payload klien).
 */
public record Tugas(int id, String judul, String pemilik, StatusTugas status, LocalDate tenggat) {

    public Tugas {
        if (judul == null || judul.strip().isEmpty()) {
            throw new IllegalArgumentException("judul tidak boleh kosong");
        }
        if (pemilik == null || pemilik.strip().isEmpty()) {
            throw new IllegalArgumentException("pemilik tidak boleh kosong");
        }
        if (tenggat == null) {
            throw new IllegalArgumentException("tenggat tidak boleh kosong");
        }
        judul = judul.strip();
        pemilik = pemilik.strip();
    }
}
