package de.antco.projekt.exporters;

import de.antco.projekt.model.Person;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.List;

public class CsvPersonExporter implements IExporter<Person> {

    @Override
    public void exportData(List<Person> data, String path) throws Exception {
        try (BufferedWriter bw = new BufferedWriter(new FileWriter(path))) {
            for (Person p : data) {
                bw.write(p.getName() + ";" + p.getPhone() + ";" + 
                         (p.getEmail() != null ? p.getEmail() : "") + ";" + 
                         (p.getAddress() != null ? p.getAddress() : ""));
                bw.newLine();
            }
        }
    }
}
