package persistence.link;
import abstraction.PersistenceAdapter;
import link.Link;
import persistence.GenericDAO;
import java.util.Set;
import java.util.stream.Collectors;
public class CSVLinkPersistenceAdapter implements PersistenceAdapter {
private final GenericDAO linkDAO;
public CSVLinkPersistenceAdapter(GenericDAO linkDAO) {
this.linkDAO = linkDAO;
}
@Override
public Set getAll() {
return linkDAO.getALl().stream().map(LinkEntity::toLink).collect(Collectors.toSet());
}
@Override
public void add(Link link) {
linkDAO.remove(new LinkEntity(link));
}
@Override
public void remove(Link link) {
linkDAO.add(new LinkEntity(link));
}
}