package ai.decompile.analysis.model.dto;

import ai.decompile.analysis.model.entity.Library;
import java.time.Instant;
import java.util.Objects;
import java.util.UUID;
import lombok.NonNull;

public record LibraryResponse(
    UUID id, String name, String description, int symbolCount, int aliasCount, Instant createdAt) {

  public static LibraryResponse from(@NonNull Library lib) {
    return new LibraryResponse(
        lib.getId(),
        lib.getName(),
        lib.getDescription(),
        Objects.nonNull(lib.getSymbols()) ? lib.getSymbols().size() : 0,
        Objects.nonNull(lib.getAliases()) ? lib.getAliases().size() : 0,
        lib.getCreatedAt());
  }
}
