package ai.decompile.analysis.model.dto;

import ai.decompile.analysis.model.entity.StaticImport;
import java.util.Objects;
import java.util.UUID;
import lombok.NonNull;

public record ImportResponse(
    UUID id,
    String dll,
    String name,
    String address,
    int ordinal,
    String resolvedName,
    String libraryName,
    String className,
    UUID librarySymbolId) {

  public static ImportResponse from(@NonNull StaticImport imp) {
    var sym = imp.getLibrarySymbol();
    return new ImportResponse(
        imp.getId(),
        imp.getDll(),
        imp.getName(),
        imp.getAddress(),
        imp.getOrdinal(),
        imp.getResolvedName(),
        Objects.nonNull(sym) ? sym.getLibrary().getName() : null,
        Objects.nonNull(sym) ? sym.getClassName() : null,
        imp.getLibrarySymbolId());
  }
}
