package com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.migration;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRedactionEntry;

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

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

    List<Mapping> mappings;

    List<ManualRedactionEntry> manualRedactionEntriesToAdd;

    List<String> forceRedactionIdsToDelete;


    public Map<String, String> buildOldToNewMapping() {

        return mappings.stream()
                .collect(Collectors.toMap(Mapping::oldId, Mapping::newId));
    }


    public Map<String, String> buildNewToOldMapping() {

        return mappings.stream()
                .collect(Collectors.toMap(Mapping::newId, Mapping::oldId));
    }


    public void addMapping(String oldId, String newId) {

        mappings.add(new Mapping(oldId, newId));
    }


    private record Mapping(String oldId, String newId) {

    }

}
