package p.packer.models;

import java.util.List;
import java.util.Objects;

public record PackerRuntimeSnapshot(
        long generation,
        PackerRegistryState registry,
        List<PackerRuntimeAsset> assets,
        PackerWorkspaceCacheState cacheState) {

    public PackerRuntimeSnapshot(
            long generation,
            PackerRegistryState registry,
            List<PackerRuntimeAsset> assets) {
        this(generation, registry, assets, PackerWorkspaceCacheState.EMPTY);
    }

    public PackerRuntimeSnapshot {
        if (generation <= 0L) {
            throw new IllegalArgumentException("generation must be positive");
        }
        registry = Objects.requireNonNull(registry, "registry");
        assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
        cacheState = Objects.requireNonNull(cacheState, "cacheState");
    }
}
