package p.packer.models;

import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

public record PackerRuntimeAsset(
        Path assetRoot,
        Path manifestPath,
        Optional<PackerRegistryEntry> registryEntry,
        PackerAssetDeclarationParseResult parsedDeclaration,
        PackerRuntimeWalkProjection walkProjection,
        List<PackerDiagnostic> walkDiagnostics) {

    public PackerRuntimeAsset(
            Path assetRoot,
            Path manifestPath,
            Optional<PackerRegistryEntry> registryEntry,
            PackerAssetDeclarationParseResult parsedDeclaration) {
        this(assetRoot, manifestPath, registryEntry, parsedDeclaration, PackerRuntimeWalkProjection.EMPTY, List.of());
    }

    public PackerRuntimeAsset {
        assetRoot = Objects.requireNonNull(assetRoot, "assetRoot").toAbsolutePath().normalize();
        manifestPath = Objects.requireNonNull(manifestPath, "manifestPath").toAbsolutePath().normalize();
        registryEntry = Objects.requireNonNull(registryEntry, "registryEntry");
        parsedDeclaration = Objects.requireNonNull(parsedDeclaration, "parsedDeclaration");
        walkProjection = Objects.requireNonNull(walkProjection, "walkProjection");
        walkDiagnostics = List.copyOf(Objects.requireNonNull(walkDiagnostics, "walkDiagnostics"));
    }
}
