package ai.decompile.workspace.model.dto;

import ai.decompile.workspace.model.entity.Binary;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.Instant;
import java.util.List;
import java.util.UUID;

public record BinaryResponse(
    @NotNull UUID id,
    @NotNull UUID projectId,
    @NotBlank String filename,
    long fileSize,
    String format,
    String architecture,
    String compiler,
    @NotBlank String filePath,
    boolean staticAnalysisDone,
    @NotNull Instant updatedAt,
    @NotNull List<BinaryDependencyResponse> dependencies) {
  public static BinaryResponse from(Binary binary) {
    return new BinaryResponse(
        binary.getId(),
        binary.getProject().getId(),
        binary.getFilename(),
        binary.getFileSize(),
        binary.getFormat(),
        binary.getArchitecture(),
        binary.getCompiler(),
        binary.getFilePath(),
        binary.isStaticAnalysisDone(),
        binary.getUpdatedAt(),
        binary.getDependencies().stream().map(BinaryDependencyResponse::from).toList());
  }
}
