package com.iqser.red.service.persistence.service.v2.api.external.model;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FileAttributeDefinitionList {

    private CsvImportSettings csvImportSettings;

    @Builder.Default
    private List<FileAttributeDefinition> fileAttributeDefinitions = new ArrayList<>();

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class CsvImportSettings {

        private String filenameMappingCsvColumnHeader;

        @Builder.Default
        private String delimiter = ",";

        @Builder.Default
        private String encoding = StandardCharsets.UTF_8.name();


        // TODO: make csvMappingActive a persistent value instead of a transient one when implementing the endpoint to set the csv mapping
        @JsonProperty("csvMappingActive")
        public boolean isCsvMappingActive() {

            return StringUtils.isNotBlank(filenameMappingCsvColumnHeader);
        }

    }

}
