This repository has been archived on 2022-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
LinkDitch/1-Adapter/src/main/java/persistence/link/CSVLinkPersistenceAdapter.java
2022-05-15 11:37:46 +02:00

33 lines
702 B
Java

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<Link> {
private final GenericDAO<LinkEntity> linkDAO;
public CSVLinkPersistenceAdapter(GenericDAO<LinkEntity> linkDAO) {
this.linkDAO = linkDAO;
}
@Override
public Set<Link> 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));
}
}