2026-03-24 13:42:55 +00:00

36 lines
1.2 KiB
Java

package p.packer.dtos;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
public record PackerPackValidationAssetDTO(
int assetId,
String assetName,
Path assetPath,
long lastModified,
List<PackerDiagnosticDTO> diagnostics) {
public PackerPackValidationAssetDTO {
if (assetId < 0) {
throw new IllegalArgumentException("assetId must not be negative");
}
assetName = Objects.requireNonNull(assetName, "assetName").trim();
assetPath = Objects.requireNonNull(assetPath, "assetPath").toAbsolutePath().normalize();
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
if (assetName.isBlank()) {
throw new IllegalArgumentException("assetName must not be blank");
}
if (lastModified < 0L) {
throw new IllegalArgumentException("lastModified must not be negative");
}
if (diagnostics.stream().anyMatch(diagnostic -> !diagnostic.blocking())) {
throw new IllegalArgumentException("validation diagnostics must be blocking in the first wave");
}
}
public boolean blocked() {
return !diagnostics.isEmpty();
}
}